ember.js

Ember JS Please load `ember-template-compiler.js` prior to calling `compile`

拟墨画扇 提交于 2019-12-23 09:50:01
问题 I am still getting the error below despite having following the instructions on this link Ember.js: HtmlBars and the Handlebars.compile command. Below I have copied and pasted my package.json,bower.json and brocfile.js. Not sure what is causing the issue. Uncaught Error: Cannot call compile without the template compiler loaded. Please load ember-template-compiler.js prior to calling compile . package.json { "name": "ui", "version": "0.0.0", "description": "Small description for ui goes here",

How to detect and save relation change in Ember 2.13.0?

拥有回忆 提交于 2019-12-23 09:47:38
问题 I have documents list. Every document has client attribute defined by belongsTo . When user change client in one of documents i want to show in the counter how many documents are changed. And when user decide he will press "publish" button which will save documents client changes to api. DS.Model in ember 2.13 has parameters (https://emberjs.com/api/data/classes/DS.Model.html): hasDirtyAttributes, dirtyType Both of them does not react on belongsTo/HasMany changes by Ember design . I saw many

Ember testing: You have turned on testing mode, which disabled the run-loop's autorun

你离开我真会死。 提交于 2019-12-23 09:27:15
问题 I am trying to write a simple Ember integration test and continue to get the frustrating run loop error despite using Ember.run . I've had a nightmare of a time trying to get this to work, if anyone could help me I'd be so grateful. Specifically, I can see the test sign in and begin loading the next page (as it should), but as soon as the test finishes I get that error. This is regarding the second test, the first passes (as nothing is async I believe). import Ember from 'ember'; import

Strongloop with Emberjs

依然范特西╮ 提交于 2019-12-23 09:27:02
问题 Ember Data's REST Adapter accepts the JSON from the server in this format: Taken from the documentation: http://guides.emberjs.com/v1.10.0/models/the-rest-adapter/ { "post": { "id": 1, "title": "Node is not omakase", "comments": [1, 2, 3] }, "comments": [{ "id": 1, "body": "But is it _lightweight_ omakase?" }, { "id": 2, "body": "I for one welcome our new omakase overlords" }, { "id": 3, "body": "Put me on the fast track to a delicious dinner" }] } Is it possible to have this kind of JSON

Ember.js: how to save a model

天大地大妈咪最大 提交于 2019-12-23 09:18:37
问题 From the ember docs its clear you should be able to save a dirty model var m = App.MyModel.find(10) ; ... m.set("firstName", "John") ; m.get("isDirty") ; // --> true Now, I don't know how to save, things like m.save() ; App.MyModel.save(m) ; //etc do not work. Any suggestions ? CHeers 回答1: EDIT: This is now out of date with Ember Data 1.0 beta and onwards, please refer to Bart's answer If you are using Ember-Data, you need to call commit() on the model's transaction. m.get('transaction')

How do I make a computed, filtered property?

Deadly 提交于 2019-12-23 08:56:38
问题 I've got something like this: Epic = Ember.Object.extend({ children:[], children_filtered: function(){ return this.get("children").filterProperty("archived",false); }.property("children"), init: function() { this._super(); this.set("children", Ember.ArrayController.create({content:[]}) ); this.set("stories", Ember.ArrayController.create({content:[]}) ); }, }); Note the children_filtered computed property. If I use children_filtered in a view... {{#each content.children_filtered }} hi {{/each}

Uncaught Error: Assertion Failed: You may not set `id` as an attribute on your model

删除回忆录丶 提交于 2019-12-23 08:55:31
问题 Entire error: Uncaught Error: Assertion Failed: You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from App.Plan Ember Model: App.Plan = DS.Model.extend({ id: DS.attr('number'), name: DS.attr('string'), period: DS.attr('number'), price: DS.attr('number') }); Data coming from REST API: {"plans":[{"id":1,"name":"Monthly subscription","period":1,"price":2}]} Question: How can I move around the above error ? 回答1: Just leave out the

EmberJS: is it possible to break from forEach?

给你一囗甜甜゛ 提交于 2019-12-23 08:47:37
问题 Is there a way to break from the forEach iterator in Ember? I tried to return false in the callback (a la jQuery) but it does not work. Thanks! PJ 回答1: Ember uses the native Array.prototype.forEach if it's available, and emulates it if not. See https://github.com/emberjs/ember.js/blob/v1.0.0-rc.1/packages/ember-metal/lib/array.js#L45. JavaScript's forEach doesn't support breaking. See https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach 回答2: You can use

What's the purpose of ArrayController and ArrayProxy?

帅比萌擦擦* 提交于 2019-12-23 08:46:22
问题 I've been digging into EmberJS for one day :). I've followed several examples. Some examples used ArrayProxy while others used ArrayController. I looked at the unminified source code and..guess what...Ember.ArrayController is simply extending Ember.ArrayProxy, but there's no extra methods or features in ArrayController. So..my question is..why do we have two same classes? 回答1: There is no difference between the two classes. It's for all of us who are coming from SproutCore 0.9.x, 1.x and

CORS preflight channel did not succeed

▼魔方 西西 提交于 2019-12-23 08:05:21
问题 I'm trying to build a Ember app with PHP REST framework as my api locally. The Ember app is being served at http://localhost:4200 and the api is being served from just http://localhost . This is causing a CORS issue. I've tried everything that I can think of, but I keep getting an error back saying the request was blocked and that the preflight channel did not succeed. It doesn't succeed in Firefox or Chrome. I've added the following to the .htaccess file for my api: Header set Access-Control