ember.js

Best approach to fetch data in every state of app

怎甘沉沦 提交于 2019-12-25 09:46:19
问题 I've discovered this jsFiddle and I'm now wondering what the best approach would be to display the list of contributors both in the IndexRoute and in all Subroutes of match('/contributor/:contributor_id') with the new v2 Router from Ember.js. The problem I'm experiencing is that App.IndexRoute = Ember.Route.extend({ model: function() { return App.Contributor.find(); } });​ is only fetching the data on the specified / route. When directly navigating to /#/contributor/[some_id] the data for the

Best approach to fetch data in every state of app

*爱你&永不变心* 提交于 2019-12-25 09:45:48
问题 I've discovered this jsFiddle and I'm now wondering what the best approach would be to display the list of contributors both in the IndexRoute and in all Subroutes of match('/contributor/:contributor_id') with the new v2 Router from Ember.js. The problem I'm experiencing is that App.IndexRoute = Ember.Route.extend({ model: function() { return App.Contributor.find(); } });​ is only fetching the data on the specified / route. When directly navigating to /#/contributor/[some_id] the data for the

Save nested models using Ember Data

喜夏-厌秋 提交于 2019-12-25 09:29:58
问题 I have two models in Ember: Collection export default DS.Model.extend({ name: DS.attr(), description: DS.attr(), items: DS.hasMany('collection-item') }); Collection Item export default DS.Model.extend({ date: DS.attr(), volume: DS.attr(), sequenceNumber: DS.attr() }); I want to save the collection items inside the 'items' attribute of the collection, like MongoDB: [{ "name": "First Collection", "description": "This is my first collection", "items": [ { "date": "2017-07-26", "volume": "1",

Array values are not getting reflected while rebinding in EmberJS

蓝咒 提交于 2019-12-25 08:47:50
问题 I have an array ( ['Name1','Name2','Name3'] ) which I am populating at page Load. Now at button click, I want to assign some other values to that array and populate the same like App.myArray = ['Name4','Name5','Name6'] But it is not reflected. Complete code <!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.1/handlebars.min.js"></script> <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script src="https://cdnjs.cloudflare

Ember: binding controller properties to query parameters

♀尐吖头ヾ 提交于 2019-12-25 08:37:08
问题 I know ember is supposed to have some built-in binding of controller properties and query params. Docs state (referring to a previous example): once the articles route has been entered, any changes to the category query param in the URL will update the category property on controller:articles, and vice versa. I take "vice versa" to mean that if there's a change to one of the controller properties, it would also be reflected in the QPs on the URL. perhaps I am mis-interpreting that. But if my

Component had no action handler for… Behaviour changes between ember 2.8.0 and 2.8.1

旧时模样 提交于 2019-12-25 08:28:18
问题 Please see this ember-twiddle. What I want is to provide custom buttons with custom actions to a component. The component itself does not know about the actions involved, these actions are expected to bubble to the corresponding controller. This code works in ember 2.8.0 but not in the current release version (2.8.2). Please use the twiddle to change between emberjs "2.8.0" and "release". Is this an emberjs bug? 回答1: Yes it's Bug in ember version 2.8.0 alone. this has been fixed in next

How to get next route after the current route deactivate.?

让人想犯罪 __ 提交于 2019-12-25 07:49:45
问题 I have some code that uses route 'deactivate' method as follows. deactivate: function() { this._super(); //some code here } Is there a way to identify where is user trying to go(route of URL) after this route deactivates? 回答1: I would encourage you to use willTransition actions method hook for this purpose since that will be called before deactivate hook method. transition.targetName will provide the target route. actions: { willTransition(transition) { this._super(...arguments); console.log(

Is it possible to periodically notify observers of a computed property with ember.js?

天涯浪子 提交于 2019-12-25 07:37:16
问题 I am trying to implement the following simple use case: have an ember template periodically display the current time. I have found a way to do it, but I suspect that there is a better/simpler way. Here is what I do: In my controller, I have a dirtyFlag property. I use this as a trick to trigger the notification of observers (hence of my template). When the application is ready, I start a timer to periodically change the value of the dirtyFlag property. I would like to avoid using the

Ember.js dynamic model requests

人盡茶涼 提交于 2019-12-25 07:13:50
问题 I am trying to make a request from the store for a model based on the result of a previous model request. Please find the code below: For the route: model(params) { var id = params.framework_id; var main = this; return Ember.RSVP.hash({ question: this.store.query('question', {orderBy: 'framework', equalTo: id}), framework: this.store.find('frameworks', id), frameworks: this.store.findAll('frameworks') }) } Then in the route there is a setupController: setupController: function(controller,

Can Ember-Data handle two models from one JSON payload?

≡放荡痞女 提交于 2019-12-25 06:58:45
问题 I have JSON coming from the server which looks like: data: { user: { address: { id: "id", city: "city", street: "street", ....... } name: "name", ...... } authentication-token: { token: "token", id: "id" } } The idea is to store this two models (user, authentication-token) in ember store under the same names. When I gat the above mentioned response from a server, model user is saved successfully, but model authentication-token does not get saved to the store at all. When I log the data (in