ember.js

how to get Ember-Data RESTAdapter to send “hasMany” records to server

徘徊边缘 提交于 2019-12-23 20:12:27
问题 I'm using Ember-Data beta 3. My Ds.models are similar to the following: App.Item = DS.Model.extend({ itemName: DS.attr('string'), strategy: DS.belongsTo('strat') }); App.Strat = DS.Model.extend({ stratName: DS.attr('string'), items: DS.hasMany('item',{async:true}) }); Using Ember-data's RESTAdapter, I'm able to populate the model using data from my server. But when I tried to persist data back to the server, none of the "App.Item" records got sent. The JSON received by my server only

Ember.js Acceptance Testing not waiting for asynchronous data operations

你。 提交于 2019-12-23 19:52:04
问题 When using the Emberfire (Firebase) adapter, I'm getting various errors that indicate the tests are not waiting for data operations to complete. eg: Error: Assertion Failed: You can only unload a record which is not inFlight. when I try to create, check, and then delete a record Also: FIREBASE WARNING: Exception was thrown by user callback. Error: Called stop() outside of a test context at Object.extend.stop (http://localhost:4200/assets/test-support.js:3000:10) at exports.default.

How can I share a template between two components using Ember CLI?

浪子不回头ぞ 提交于 2019-12-23 19:24:47
问题 I have two components: SpecialButtonComponent and SpecialButtonDerivativeComponent . The SpecialButton component automatically uses the template found at /app/templates/components/special-button.hbs . I would like for SpecialButtonDerivativeComponent to use the same template, but so far I'm having no luck trying to go with this technique: // app/components/special-button-derivative.js import SpecialButtonComponent from './special-button'; export default SpecialButtonComponent.extend({

How to modify the sortProperties value dynamically inside an ember.js ArrayController

早过忘川 提交于 2019-12-23 19:24:01
问题 I'm using ember 1.0 pre and have a basic array controller that starts out with a default sort property of 'id' PersonApp.PersonController = Ember.ArrayController.extend({ content: [], sortProperties: ['id'], updateSort: function(column) { this.set('sortProperties', column); } }); I'd like to set this dynamically and have the dom updated for free. But when I do a simple setter (shown above) it doesn't update anything in my view or on the dom. If I need the ability to update this dynamically

Rendering a view inside #each

不想你离开。 提交于 2019-12-23 19:15:10
问题 Whenever I try to render a view inside an #each block, I get a PrecompilationError saying: Compiler said: Error: each doesn't match view . Example: {{#each posts}} {{view App.MyPost}} <div>Some HTML here</div> {{/view}} {{/each}} I need to do some stuff when before a single post is rendered, so my guess was that I need a custom view (App.MyPost) to implement the 'willInsertElement' hook. What am I doing wrong? 回答1: You're missing a # If you want to use an inline template, the view helper

How to return a deferred promise and create a model with Ember.Deferred?

与世无争的帅哥 提交于 2019-12-23 18:34:01
问题 I'm trying to create a User.current() in my application, which pulls data from my server using $.getJSON('/users/current', function(data) { ... }); . I am using the Singleton method that Discourse uses, which does the following: Dashboard.Singleton = Ember.Mixin.create({ // See https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/mixins/singleton.js current: function() { if (!this._current) { this._current = this.createCurrent(); } return this._current; },

Data binding: property of model object changes from integer to string

╄→гoц情女王★ 提交于 2019-12-23 18:26:35
问题 In my app a model object myModelObject with a property foo is created. Initially foo is set to an integer. foo can be modified in an input form field. Modifying foo in this form field to be some other integer results in foo changing to be a string. Example w/o Ember Data: http://jsbin.com/qahafapixebe/3/edit Example with Ember Data: http://jsbin.com/nujesovugudo/2/edit Is there a way to ensure that a property stays an integer after being modified via form field? Note: App.myModelObject.set(

Recording values of radio buttons in ember

自古美人都是妖i 提交于 2019-12-23 17:56:28
问题 I am fairly new to Ember (using version 0.2.3). I have a component with a few computed values. They gather these computed values from input fields: export default Component.extend({ loanAmount : 200000, deductible : 0, debtInt : 5, getLoanCosts: computed('loanAmount', 'debtInt', function(){ return (get(this, 'debtInt')/12) * get(this, 'loanAmount'); }) On my template.hbs, I have an input field {{ input value=loanAmount }} and I can call {{getLoanCosts}} in my template.hbs, to show the

Applying JQuery effect when ember-data has finished loading and element is rendered

谁说胖子不能爱 提交于 2019-12-23 17:40:30
问题 I have a list of items that I want to make draggable. I am using ember-data to get the items from my API and then render them in a view with an ArrayController. I can successfully load the items and render them but I don't know where or when to put the JQuery draggable function. I have tried using didInsertElement on my view but this is triggered when the view is rendered and not when the items are loaded. I have also tried to put an observer on my ArratController to run the code when the

ember component based on model type

。_饼干妹妹 提交于 2019-12-23 17:19:09
问题 I know this is somewhat duplicated, but All my efforts to create a dynamic component renderer are failing possibly due to my lack of knowledge in ember concepts. My Scenario is a multi purpose search bar which will search for models in the cache. I would like each search result to be rendered below the search input according to the model's type key. the handlebars file will be named according to the model type with the syntax components/app-search-<model-type-key>.hbs e.g. the template name