ember.js

In Ember, how to defer readiness, and put AJAX result into a Controller?

假装没事ソ 提交于 2019-12-12 07:16:10
问题 I understand that Ember.Application now has deferReadiness that lets me wait for the return of an AJAX call before initializing the app. However, in the example in the api docs, they put the value into a global variable in the App: App = Ember.Application.create(); App.deferReadiness(); jQuery.getJSON("/auth-token", function(token) { App.token = token; App.advanceReadiness(); }); Rather than introducing a global variable for the token, I want to place the returned value into my

How do I deploy Ember.js app developed with ember-cli on github pages?

不问归期 提交于 2019-12-12 07:06:38
问题 I have successfully created a small application using ember-cli. I tried pushing it to gh-pages branch of my github repo but it shows error in browser console Uncaught ReferenceError: require is not defined loading of vendor.js and vendor.js files from dist/assets is also failing. I'm not able to run standalone ember app from dist folder in local machine as well, same errors. has anyone tried it. if yes how to do it correctly? 回答1: Since December 2014 there is also an ember-cli addon for this

Passing parameters to ember components naming convention [closed]

为君一笑 提交于 2019-12-12 06:36:42
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . Which of the following is better practice? {{my-component title=model.title body=model.body}} or {{my-component model=model}} Is there any difference between the two, or does it not really matter? 回答1: It's difficult to not subjectively judge something like this. But let's

emberjs getEach method does not work as expected

六月ゝ 毕业季﹏ 提交于 2019-12-12 06:32:18
问题 I have the following code which I expect to return [1000] but returns [undefined]: this.get('details').getEach('gross_total') But this.get('details')[0].get('gross_total') does work and returns 1000. I am using rc3 right now. The same code in rc1 worked fine. My persistence layer is taken from discourse. The relevant models are below. Invoice has_many details App.Invoice = App.Model.extend App.Commentable, invoice_number: App.Attr('string') description: App.Attr('string') issue_date: App.Attr

Ember computed alias on array firstObject not working

本小妞迷上赌 提交于 2019-12-12 06:18:39
问题 I have this computed property alias in my component: firstElement: Ember.computed.alias('myArray.firstObject') This works in development, but doesn't update in production mode. This code though works in both development and production: firstElement: Ember.computed('myArray.[]', function() { return this.get('myArray.firstObject'); } Is the alias macro not allowed on firstObject , lastObject, etc..? It also seems weird that in works in development but not in production mode. 来源: https:/

How to link-to a specific rails API route with server-generated content in ember?

冷暖自知 提交于 2019-12-12 06:14:32
问题 I have a mixed Ember/Rails app with a Rails route in the API namespace to take any single Event and convert it to an .ics file for import into a user's calendar (a la this question). Ember is running with the command ember server --proxy http://localhost:3000 , which is connecting it to the Rails server process. The below snippets illustrate my setup: Rails routes.rb snippet: namespace :api do # snip resources :events do # snip get 'export_event_ical', on: :member end end Rails events

Relation is DS.PromiseMany instead model and data

本小妞迷上赌 提交于 2019-12-12 06:09:24
问题 What I need is: 1) Represent list of partners App.Partner= DS.Model.extend( { name: attr(), site: attr(), contacts: DS.hasMany('partner-contact', { async: true, polymorphic: true }) } ); 2) and names of partners contacts App.PartnerContact = DS.Model.extend( { name: attr(), phone: attr(), post: attr(), email: attr(), partnerId: attr(), partner: DS.belongsTo('partner') } ); So I have route: App.CallsMyContactsRoute = Ember.Route.extend({ //needs: "partner-contacts", model: function () { return

ember.js, How do I load related models while loading main model from server that is not support sideloading

≡放荡痞女 提交于 2019-12-12 06:08:40
问题 I'm ember.js newbie and facing daily problems :-) Today's problem is my server backend doesn't support sideloading . (If I understood 'sideload' right, it is server returns related models at once with multiple JSON root) for example, my server only returns below per request: for /api/v1/posts.json { posts: [{ id: 91, title: "ember.js" }, { id: 81, title: "ember-data.js" }] } for /api/v1/comments.json { comments: [{ id: 928, postId: 91, }, { id: 927, postId: 92, }] } When I load post model, go

Ember parent child component, how to avoid unnecessary life cycle hook from triggering?

孤者浪人 提交于 2019-12-12 05:59:54
问题 Child component property update is triggering all the parent component willUpdate , willRender , didUpdate and didRender life cycle hook methods. but I just updated property which is visible only the child component, It has nothing to do with parent component. Twiddle to check. Twiddle to check with powerselect - when mouse over dropdown option it's triggering the all of its parent component willUpdate , willRender , didUpdate and didRender life cycle hook methods. Is there any way I can

Emberjs how to bind-attr an id

半世苍凉 提交于 2019-12-12 05:59:38
问题 I want to use ember properties to toggle the visibility of a div by calling it's dynamic id, however even though I can do something similar by calling classes, I cannot do the same for id's. For example: {{bind-attr class=":class1 controller.controllerProperty:class2"}} works fine. I can toggle the controllerProperty from an action in my controller. You would think the same concept would apply to id's. However {{bind-attr id=":staticId controllerProperty:id{{dynamicIdNumber}}"}} makes the id