ember-data

emberjs form creates a new record but the edit form doesn't bind to new record

自作多情 提交于 2019-12-25 01:56:06
问题 I have been bumping my head concerning editing a child record that is already created. I am using thesame form partial for both creating and editing. I am able to create a child record successfully with that form partial, but if I click edit, for some reason, the edit form does not display or contain the just created record, the edit form is basically empty. To reproduce the error , don't add comments via the fixtureAdapter. If the record is in the comment fixtureAdapter you will see the

EmberJS global websocket connection

ⅰ亾dé卋堺 提交于 2019-12-25 01:45:57
问题 Im using EmberJS and im trying to get data from the backend using websocket (socket.io) so i've set this Application Route App.ApplicationRoute = Ember.Route.extend( setupController: (controller, data) -> store = @get 'store' socket = io.connect "http://localhost:4000/orders" ## Line 4 socket.on "new_order", (order) -> store.load(App.Order, order) socket.on "new_billing", (bill) -> store.load(App.Bill, bill) socket.on "connected", -> console.log "Ready" model: -> return { title: "Ordenes" }

Loading relationship model in Ember data

三世轮回 提交于 2019-12-25 00:14:11
问题 I have certain doubts with respect to Ember Data. I have a post and comments model. //post.js comments: DS.hasMany('comment') //blog.js post: DS.belongsTo('post') I can create a comment for a particular "post" using let blogPost = this.get('store').findRecord('post', 1); let comment = this.get('store').createRecord('comment', { post: blogPost }); But how can i fetch all the comments for a particular post? Like, I have multiple posts which has many comments and i want all the comments for a

Accessing rails relationships with Ember.js

风流意气都作罢 提交于 2019-12-24 19:37:03
问题 I'm just starting to learn ember and am writing a simple app that reads from a database. I've gotten it to work with fixtures how I want and have just started making some progress reading from a database. Right now my problem is that I can't access children elements - I have a parent class that I am responding to with json through a serializer, and I am serving the children elements in the json request. However, I don't know where to go from here to get the parent class in ember to read and

ember-data: modeling a user-maintained list of products

瘦欲@ 提交于 2019-12-24 19:30:40
问题 Trying to wrap my head around how to efficiently model and code a "saved items" list for logged-in users. I want the user to be able to click "save item" from a product page, and it will add the item to a list kept in their user profile that has its own route that displays their items and allows them to manage the list. On that route, anytime there are changes to the list (like, item is removed), it should refresh to reflect the changes. I'd think the user model would look something like this

Ember group binding

走远了吗. 提交于 2019-12-24 16:58:23
问题 I'm looking for a good way to bind grouped objects and render it to the grid. Here's a grid example: | League / Country | Canada | United States | Brazil | | 1 | John, Sam | | Tim | | 2 | Liam | | Robert | | 3 | | James, Peter, Tom | Den | And Player's model DS.Model.extend({ name: DS.attr(), country: DS.attr(), leagueId: DS.attr("number") }); And data received from backend is: [ { name: "John", country: "Canada", leagueId: 1 }, { name: "Sam", country: "Canada", leagueId: 1 }, { name: "Tim",

Save record of model is not working in ember-data 1.0.0-beta.3?

a 夏天 提交于 2019-12-24 16:05:06
问题 What I have done - Model - App.Book = DS.Model.extend({ book_name: DS.attr('string'), edition: DS.attr('string') }); Router - App.Router.map(function() { this.resource('books', function() { this.route('new'); }); }); App.BooksNewRoute = Ember.Route.extend({ model: function() { return this.store.createRecord('book'); }, actions: { save: function() { this.modelFor('newBook').save(); } } }); Now Can anybody help me.. How to save data ? I am getting error like TypeError: this.modelFor(...) is

Getting the model inside a controller emberjs

大憨熊 提交于 2019-12-24 15:12:50
问题 I need to get the grand total price of all the objects returned from a JSON API. my idea is to create a controller and set a property on it. Then grab the model loop over each object and add to the predefined property that objects total price. Something like this: export default Ember.Controller.extend({ orderTotal: 0, getOrderTotal: function(){ var model = this.get('model'); model.forEach(function(c){ var order_total = this.get('orderTotal') * c.total_price; this.set('orderTotal', order

Automatically generating IDs with Ember & Firebase

浪子不回头ぞ 提交于 2019-12-24 14:13:08
问题 I'm trying to generate ID's for a model. Ember documentation says that Ember automatically generates IDs for its models. But when I pass data to Firebase and try to display it, the IDs return undefined. Is there something wrong with my code? <script type="text/x-handlebars" id="stack"> <div class='stack'> <div class="container"> <div class="row"> <div class="span12" style="text-align:center; margin: 0 auto;"> {{#if isEditing}} {{partial 'stack/edit'}} <button {{action 'doneEditing'}}>Done<

How to dynamic update 2 templates simultaneously in emberjs

吃可爱长大的小学妹 提交于 2019-12-24 14:03:09
问题 in the folowing jsFiddle i have add a little example ember application. In the 'details' view i want to display information about the selected group and if i click on a device in a group, i want to replace the details with the device details. How can i manage this in ember way? http://jsfiddle.net/theremin/qGCe6/1/ TEMPLATES <script type="text/x-handlebars" data-template-name="application"> <h2>SampleApp</h2> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="groups">