ember.js

Ember.js commiting parent model with already existing child models

元气小坏坏 提交于 2019-12-14 03:43:45
问题 Cheers! For example I have three models: App.Foo = DS.Model.extend({ bars: DS.hasMany('App.Bar', {embedded:'always'}), bazes: DS.hasMany('App.Baz', {embedded:'always'}) }); App.Bar = DS.Model.extend({ foo: DS.belongsTo('App.Foo') }); App.Baz = DS.Model.extend({ foo: DS.belongsTo('App.Foo) }); And adapter mappings like these: App.RESTSerializer = DS.RESTSerializer.extend({ init: function() { this._super(); this.map('App.Foo', { bars:{embedded: 'always'}, bazes:{embedded: 'always'} }) } }); I'm

performing rollback on model with hasMany relation

帅比萌擦擦* 提交于 2019-12-14 03:43:13
问题 I have models defined as : App.Answer = DS.Model.extend({ name: DS.attr('string'), layoutName: DS.attr('string') }); App.Question = DS.Model.extend({ name: DS.attr('string'), answers: DS.hasMany('answer', {async: true}) }); I have a component that allows for deleting and adding answers to question model. The component comes with apply and cancel button and when the user clicks on cancel, I wanted all the changes(adds/deletes of answers) to be reverted. Currently rollback doesn't do the trick,

Ember 3.2.2 not routing request to .NET Core 2.1 JSON web API

不打扰是莪最后的温柔 提交于 2019-12-14 03:34:02
问题 I am new to using Ember and have been following an online video tutorial (see weblink below, though its dated as it uses .NET Core 1.0) that demonstrates how to setup a JSON API back-end with an Ember front-end - I am using Visual Studio Code. I have successfully completed the first video and receive responses from the JSON API back-end. However, I am unable to get the second video working by having Ember send a request to the api-back end for data retrieval. I know this because I am

How can I force Ember to get into the second level of an object in a template using a helper function?

久未见 提交于 2019-12-14 03:15:49
问题 I have a 'has-many' helper (thanks to the help of @GJK in In an ember component template how can I use 'if' to check for at least one of an array having a property equal to X?) that allows me to check one level of an array in my template for a match on a property: helpers/has-many.js import Ember from 'ember'; // Param[0]: Array to iterate over // Param[1]: Comparison operator to use, currently supports '===', '>', '<' and nested 'has-any' // Param[2]: Value to check for // (Optional) Param[3

Ember js get array index of clicked element in an each loop, and filter with it

江枫思渺然 提交于 2019-12-14 03:14:00
问题 I am trying to implement the following: My controller returns an array of posts, which fall into a certain category. I am displaying the titles of each of those posts on the left hand side of the page. On the right side of the page, I would like to display an area where the full text of only one post displays. This would be the first post initially, but would change when a different post title is clicked. I am currently trying to achieve this using two each helpers in my template: templates

ember.js: prepare code to move from ember 1.x to ember 2.0

霸气de小男生 提交于 2019-12-14 02:35:41
问题 My question is: Can someone direct me in moving from controller based application to component base application? I am building a map application for my dog training club. We are specialized in helping finding missing people. In order to organize our training, we need an application to draw trails and add items on them etc. I've started an app using Ember-Cli and OpenLayers-3. The application is working nicely, but I would like to move the code from controller based to component base approach.

Adding class based on multiple conditions in bind-attr

廉价感情. 提交于 2019-12-14 02:27:30
问题 I am needing to add an error class based on two values: <div {{bind-attr class="anyErrors:errors.email:ui-input--error"}}> So if anyErrors is true AND errors.email is true it puts the class on the div. I have tried several things but nothing seems to work. Any help is much appreciated. 回答1: Just use a normal computed property in this case. Ternary form inside of templates is good for simple logic, but gets smelly with multiple conditions. So: <div {{bind-attr class="anyErrors:errors.email:ui

How to stub component's action in ember?

前提是你 提交于 2019-12-14 02:24:52
问题 I created a component, whose action uses store service. How can I stub this action from integration test? // app/components/invoice-form.js export default Ember.Component.extend({ actions: { loadPartners() { let self = this; this.get('store').findAll('partner').then(function(partners) { self.set('partners', partners); }); } } }); In this component's template I pass this action as closure to child component: {{button-confirmation text="Are you sure?" onConfirm=(action "loadPartners")}} In my

Assertion failed: The value that #each loops over must be an Array. You passed [object Object]

隐身守侯 提交于 2019-12-14 02:24:39
问题 I am trying to change the model for a template at runtime when a button is pressed. For changing the model of template called 'example', changeModel action is called on button press. This method makes an Ajax request and gets some data from the backend. Now the problem is that the app transitions to the example template but the new data is not displayed in the template. I verified that the data is being sent from the server. When I put exactly same data into a variable and try to load that as

Cannot save model when using ember render helper

你说的曾经没有我的故事 提交于 2019-12-14 01:54:53
问题 I'm rendering a model into a parent template like this: {{render "teacher" teacher}} Here's it's controller: App.TeacherController = Ember.ObjectController.extend(App.EditableModelMixin, { actions: { saveTypes: function() { if (this.get('model')) console.log('Exists'); console.log(this.get('model')); console.log(this.get('model').get('isFulfilled')); this.get('model').save(); } } }); Here's the output when this method is called: Exists Class {isFulfilled: true, toString: function, constructor