ember-model

Switch from Ember Data FixtureAdapter to Ember Model FixtureAdapter

你。 提交于 2019-12-25 10:51:05
问题 After I learned that the BasicAdapter in Ember Data has been removed, I decided to switch from Ember Data to Ember Model because the API I work with is not totally RESTful (and I need more flexibility in general). I'm wondering how to "translate" some parts of my code that used to work with the FixtureAdapter from Ember Data. Here for example, I get a list of profiles but I want to directly redirect to the first one. That means, accessing /profiles will redirect me to something like /profiles

Right way to make AJAX GET and POST calls in EmberJS

妖精的绣舞 提交于 2019-12-24 07:10:03
问题 I've started working on EmberJS and I absolutely love it. It does have a learning curve but I believe it has fundamentally very meaningful principles. My questions is how to make GET and POST calls in Ember JS. I understand that there are models / store, but models (in my opinion) would be to only a particular entity's attributes. Any thoughts on the following questions would be great. 1. USER A send friend request to USER B. Should there be a "Request" model? And do I just make a POST

Ember deeply nested routes do not keep parent dynamic parameter

吃可爱长大的小学妹 提交于 2019-12-22 04:03:59
问题 I've got this ember application: Ember : 1.3.2 Ember Model : 0.0.11 Handlebars : 1.3.0 jQuery : 1.9.1 Using this resource map: App.Router.map(function () { this.resource('dimensions', function() { this.resource('dimension', { path: ':dimension_id'}, function () { this.resource('value', { path: 'values/:value_id' }); }); }); }); And this allows me to embed {{outlet}} in "dimensions" template that fills with "dimension" template, and embed {{outlet}} in "dimension" template that fills with

Iterate over an ember model query

你说的曾经没有我的故事 提交于 2019-12-17 20:55:15
问题 this.store.findAll('game').then(function(results){ // RUN SOME OPERATION ON THEM }) I would like to know how I can play with the results variable. I understand I can do results.get('firstObject') // returns the first object. I'd like to know everything else I can do with it. Is there any api documentation for the results collection? Thanks! 回答1: From ember guides, The below methods, will return the Promise, it will be resolved to Record or RecordArray. store.findAll() returns a DS

child records and ember model

安稳与你 提交于 2019-12-12 21:28:53
问题 [Update] Thanks for the help so far. I've been able to create a new Post record with an embedded Comment record with static data. Via this method: App.CommentsController = Ember.ArrayController.extend({ needs: "post", actions: { addComment: function() { var post = App.Post.create({ title: 'static post' }); post.get('comments').create({ message: 'static message' }); post.save(); } } }); But I'm falling short figuring out how to retrieve the current Post via the CommentsController or Route in

Ember-Model hasMany does not save model emberjs

走远了吗. 提交于 2019-12-11 23:09:45
问题 I am trying to achieve this Department -HasMany->Contacts. Have no clue Department gets saved but Contacts doesnt get Saved you can refer this section in jsbin App.NewcontactController = Ember.ObjectController.extend({ needs: ['department'], save: function () { var department = this.get('controllers.department').get('model'); var newContact = App.Contact.create({ name: this.get('name'), department: department }); department.get('contacts').addObject(newContact); console.log(department);

How to Add Child Record to Existing Parent Record?

女生的网名这么多〃 提交于 2019-12-06 04:54:29
问题 I've been googling and scouring Stack Overflow for some sort of hint on this subject but the information is scattered at best. I'm trying to Create a new Child Record ( Comment ) and save it to an existing Parent Record ( Post ). I am using Ember-Model, rather than Ember-Data, but any tips or pointers would be greatly appreciated. At the moment, I've been successful creating a new, embedded Comment but only when it is created with a new Post record. So: How do I go about loading/retrieving

Ember deeply nested routes do not keep parent dynamic parameter

泄露秘密 提交于 2019-12-05 01:32:34
I've got this ember application: Ember : 1.3.2 Ember Model : 0.0.11 Handlebars : 1.3.0 jQuery : 1.9.1 Using this resource map: App.Router.map(function () { this.resource('dimensions', function() { this.resource('dimension', { path: ':dimension_id'}, function () { this.resource('value', { path: 'values/:value_id' }); }); }); }); And this allows me to embed {{outlet}} in "dimensions" template that fills with "dimension" template, and embed {{outlet}} in "dimension" template that fills with "value" template as well. All works very well except for the link-to helper in the "value" template, that

How to delete all records associated with an ember model without clearing local Storage?

送分小仙女□ 提交于 2019-12-01 04:42:22
I have extended the program given in this stackoverflow answer to have a program that deletes all the records all at once. However, the deletion happens only in batches and does not delete everything all at once. Here is a snippet of the function I am using in this JSBin . deleteAllOrg: function(){ this.get('store').findAll('org').then(function(record){ record.forEach(function(rec) { console.log("Deleting ", rec.get('id')); rec.deleteRecord(); rec.save(); }); record.save(); }); } Any idea how the program can be modified such that all records can be deleted at once? I have also tried model

How to delete all records associated with an ember model without clearing local Storage?

大憨熊 提交于 2019-12-01 02:52:29
问题 I have extended the program given in this stackoverflow answer to have a program that deletes all the records all at once. However, the deletion happens only in batches and does not delete everything all at once. Here is a snippet of the function I am using in this JSBin. deleteAllOrg: function(){ this.get('store').findAll('org').then(function(record){ record.forEach(function(rec) { console.log("Deleting ", rec.get('id')); rec.deleteRecord(); rec.save(); }); record.save(); }); } Any idea how