ember.js

Serialize JSON into Ember-Data (two different models in payload)

蹲街弑〆低调 提交于 2019-12-25 02:08:21
问题 I have JSON coming from the server which looks like: data: { user: { address: { id: "id", city: "city", street: "street", ....... } name: "name", ...... } authentication: { token: "token", id: "id" } } In Ember I have a model auth which should represent the authentication model that I get from the server. Since I have different names for same model on the server and in the Ember store, I wrote a serializer with one method typeForRoot(root) where I just map server authentication to Ember auth

How can we reload a route Ember JS (versoin 1.0.0-rc.1)

China☆狼群 提交于 2019-12-25 02:07:20
问题 I have a condition where my route: application.com/#/sample/:id is redirected back to application.com/#/sample/:id For example, application.com/#/sample/1 gets an event which redirects to application.com/#/sample/2 This does not cause a reload. Has any one got this case fixed? Actually I am having a case application.com/#/parent/123/sample/1 causing redirect to application.com/#/parent/123/sample/2 Event is received by ParentRouter to transitionTo("parent.sample",{id:2}) . What I get in the

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 1.0.0-RC3: using NEEDS-API to access other controller content property

余生颓废 提交于 2019-12-25 01:55:54
问题 I want to render events and appointments on thesame page. But when I use the needs api from the AppointmentController to have access to EventsController , I can see that it returns appointments inside the 'events controller content property' when inspected. But when i try to use that returned content that contains 'appointments' to fetch out the appointments it fails. I am fetching events content in AppintmentsController with eventAppt = this.get('controllers.events').get('model'); which

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" }

Ember component what is layout and how to write the functions?

末鹿安然 提交于 2019-12-25 01:35:29
问题 I created a component, it gives the output as : import Ember from 'ember'; import layout from '../templates/components/sample-work'; export default Ember.Component.extend({ layout }); When i try to add some init method like : import Ember from 'ember'; import layout from '../templates/components/sample-work'; export default Ember.Component.extend({ layout, init(){ alert.log('hi'); } }); My component not at all called. what is the issue here? what is the correct way to handle the component

How to exclude an object's id property before or during $.toJSON

[亡魂溺海] 提交于 2019-12-25 01:22:23
问题 I'm writing a custom REST adapter for ember-data users with a django rest framework app and need to build a JSON string to do POST/PUT. The only problem is I can't seem to chain another jQuery method after the $.toJSON that removes this. So far I have an ember.js object that I plan to extract each property from, except my django app doesn't want the id to go along with the HTTP POST I can get a legit string like so $.param(record.toJSON()); This results in the following id=0&username=dat I'd

How can I trigger an action, when a template is loaded in ember?

时光怂恿深爱的人放手 提交于 2019-12-25 00:39:22
问题 each time, a template is shown, i'd like to do something -- for example an alert. Here is a minimalistic example of these templates: <script type="text/x-handlebars"> {{outlet}} </script> <script type="text/x-handlebars" id="index"> index template. {{#link-to "other"}} go to other Template {{/link-to}} </script> <script type="text/x-handlebars" id="other"> other template {{#link-to "index"}} go to index {{/link-to}} </script> I tried the following, but none of these 2 versions worked. App

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

Ember - how to create and bind a Checkbox controller?

Deadly 提交于 2019-12-24 23:26:33
问题 This question is linked to the answer given here. Having a checkbox in a view App.RoleCheckbox = Em.Checkbox.extend({ userRolesBinding: 'parentView.user.roles', // Points to the roles of the user checked: function () { var userRoles = this.get('userRoles'); return userRoles.contains(this.get('content')); }.property('content', 'userRoles.@each'), click: function (evt) { //do something var controller = this.get("controller"); controller.clicked(evt); } }); I would like that the click function