ember-data

Model reloading with Ember Data

南笙酒味 提交于 2019-12-22 04:33:10
问题 I'm trying to poll for more data using the documented model.reload() function App.ModelViewRoute = Ember.Route.extend({ actions: { reload: function() { this.get('model').reload(); } } }); But i'm getting an error message saying... undefined is not a function TypeError: undefined is not a function Is there a better way of doing this, it seems like I cannot access the model in this way from the route? Here is the router App.Router.map(function() { this.route('video', { path: '/videos/:video_id'

Ember.js Data how to clear datastore

风流意气都作罢 提交于 2019-12-22 04:09:49
问题 I am experiementing with Ember.js and have setup a small app where users can login and logout. When the user logs out I want to clear all of the currently cached records in the Data Store. Is there a way to do this or would I have to force the browser to reload the page? 回答1: Clearing the data store is not yet supported in Ember-Data. There is an open issue concerning this on the Github tracker. 回答2: I know this question is from 2013. But since Ember Data 1.0.0-beta.17 (May 10, 2015) there's

DEPRECATION: The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one

こ雲淡風輕ζ 提交于 2019-12-22 03:35:14
问题 At the moment of this question i'm running the latest Ember and Ember Data versions. I'm working with the DS.RESTAdapter calling for a /places this way: this.store.findAll('place'); The model only have a name attribute name: DS.attr('string') The JSON is the following: { places: [ { id: 1, name: "San Francisco" }, { id: 2, name: "Havana" } ] } I made the template and with the corresponding each and everything shows up and works so far but i get a deprecation warnings that tells the following:

EmberJS CRUD : deletedRecord keeps re-appearing after linkTo

家住魔仙堡 提交于 2019-12-22 01:21:25
问题 I have an issue with deleting records from an Ember.JS model. I have an overview of records in my handlebars template with a delete button for each row. When clicking the button I would like to remove that row from the table (and execute a DELETE on my REST API). My handlebars template contains the following table + delete button for every record. <table class="table table-hover"> <tr> <th>Latitude</th> <th>Longitude</th> <th>Accuracy</th> <th></th> </tr> {{#each model}} <tr> <td>{{latitude}}

How to render hasMany associations each with their own controller

﹥>﹥吖頭↗ 提交于 2019-12-22 00:25:31
问题 So my models are set up like this : App.Post = DS.Model.extend comments: DS.hasMany 'App.Comment' App.Comment = DS.Model.extend post: DS.belongsTo 'App.Post' I'm trying to create a view that has all posts and all comments display, but I need to decorate the comment objects. This is what I'd like to do but, to no avail : <ul> {{#each post in controller}} <li>{{post.title}}</li> <ol> {{#each comment in post.comments itemController="comment"}} <li>{{comment.body}}</li> {{/each}} </ol> {{/each}}

How to update just 1 record in Ember.js with Ember-data? Currently save() and commit() on 1 record actually updates all records of model

北城以北 提交于 2019-12-22 00:14:52
问题 Premise: My question is based on my research of Ember-data, which may or may not be correct. So please correct me if I have any misunderstanding. The examples are running with the latest ember as of July 2, 2013. To edit a record of my model, just 1 record, you need to call this.get('store').commit() or this.get('model').save() . However, downstream of either of these functions actually have to update all of the records of the model, even those left untouched. So this is quite inefficient,

Ember Data sideloaded properties being dropped on a model

ⅰ亾dé卋堺 提交于 2019-12-21 22:10:06
问题 I'm working with Ember RC3 Ember Data Revision 12 Handlebars RC3 I have Ember Data sideloading relationships on many of my models, so that I can template the sideloaded relationships like so: // Models App.Client = DS.Model.extend({ company: DS.attr('string'), accountNumber: DS.attr('string'), startDate: DS.attr('mysqlDate'), // Relationships campaigns: DS.hasMany('App.Campaign'), users: DS.hasMany('App.User'), phones: DS.hasMany('App.Phone'), addresses: DS.hasMany('App.Address') }); App.User

belongsTo promise is unsettled when serializing a modified record

北慕城南 提交于 2019-12-21 20:16:10
问题 Okay the obligatory information: DEBUG: ------------------------------- DEBUG: Ember : 1.3.1 DEBUG: Ember Data : 1.0.0-beta.7.f87cba88 DEBUG: Handlebars : 1.0.0 DEBUG: jQuery : 1.10.2 DEBUG: ------------------------------- Here are the relevant models: App.Destination = DS.Model.extend({ label: DS.attr('string'), destinationMatchRules: DS.hasMany('destinationMatchRule', { async: true }), chargeRules: DS.hasMany('chargeRule', { async: true }), }); App.ChargeRule = DS.Model.extend({ startDate:

Ember Data: Get a Model in the Console

耗尽温柔 提交于 2019-12-21 12:11:51
问题 I have the simplest possible Ember app in this JSBin. All I'm trying to do is find a model. Based on other SO questions, I've tried the following. App.User.get('store').find('user', 1); App.User.Store.find('user', 1); I've defined App.Store , but App.Store returns undefined in the console. I'm obviously missing the absolute most basic concepts of Ember models. Explain like I'm 5, please? I literally just want to return a user object and call a property on it. 回答1: The store is injected to

Define the ember data model for nested rest url

走远了吗. 提交于 2019-12-21 11:35:22
问题 I am trying to do something that sounds simple but I can't find the solution. My application needs to edit documents which contains pages. Here is my model : MyApplication.Document = DS.Model.extend({ title: DS.attr('string'), pages: DS.hasMany('page', {async: true}) }); MyApplication.Page = DS.Model.extend({ document: DS.belongsTo('document', {async: true}), title: DS.attr('string'), params: DS.attr(), objects: DS.attr() }); And the routes : MyApplication.Router.map(function () { this