ember.js

Ember Data Save method, Create vs update

只愿长相守 提交于 2019-12-22 11:57:47
问题 I can't figure out how Ember determines if it should update or create a record. I would assume its based on the ID or on the Store entry, but it seems to be something else. The code example clarifies: // this returns the user without making an api call currentUser.get('store').find('user_detail', '49') // this returns 49 currentUser.get('id') // this returns true currentUser.get('store').hasRecordForId('user_detail', 49) // this issues a create to api/userDetails instead // of updating /api

Ember Data Save method, Create vs update

爱⌒轻易说出口 提交于 2019-12-22 11:57:11
问题 I can't figure out how Ember determines if it should update or create a record. I would assume its based on the ID or on the Store entry, but it seems to be something else. The code example clarifies: // this returns the user without making an api call currentUser.get('store').find('user_detail', '49') // this returns 49 currentUser.get('id') // this returns true currentUser.get('store').hasRecordForId('user_detail', 49) // this issues a create to api/userDetails instead // of updating /api

Ember Data: A data hash was loaded … but no primary key 'undefined' was provided

拈花ヽ惹草 提交于 2019-12-22 11:15:56
问题 I'm trying to use Ember Data to load a model. The AJAX call to fetch the model seems to be successful but I get the following Uncaught Error: assertion failed: A data hash was loaded for a model of type App.Account but no primary key 'undefined' was provided. In ember-data.js:1128 it seems to be deferencing undefined for the primaryKey and not defaulting to 'id' when a model doesn't specify a primaryKey. But I've also tried being explicit with the primaryKey to no effect. For completeness,

Ember.js binding models stored within an array

旧巷老猫 提交于 2019-12-22 11:13:28
问题 What is the 'correct' way to bind from one model to another when the models are stored within an array? Typically I'd imagine that this would be a Controller's content array, but to keep the example simple: MyApp.websites = []; MyApp.websites.push(Ember.Object.create({ name: "Stackoverflow" })); MyApp.websites.push(Ember.Object.create({ name: "Serverfault" })); MyApp.favorite = Ember.Object.create({ // how should this be bound to a specific element of MyApp.websites? nameBinding: ????????? })

Global keyDown/keyPress events in EmberJS without having to set focus

给你一囗甜甜゛ 提交于 2019-12-22 11:06:40
问题 I used to have a jQuery app, that had a 'keydown' event once the document was ready. Basically, anytime a user hit a key, it would match the keycode and do something. Now I ported this app to Ember and life became difficult for 2 reasons: 1) The only time a 'keyDown' event can be registered is when the containing element/View has a focus on it. The only way this can be done with non-input fields is by setting the tabindex value, to achieve this, I do this: didInsertElement:function(){ this.$(

add a name attribute to a Ember.TextField?

坚强是说给别人听的谎言 提交于 2019-12-22 10:46:24
问题 Its been a long day and this is probably extemely simple but how do i add a name attribute to a Ember.TextField ? I want to do something like this : {view Ember.TextField valueBinding="your_name" placeholder="Your name" name="your_name"}} This works with the placeholder but ignores the name. Any ideas ?? thanks Rick 回答1: The name attribute is not bound by default, see As a workaround, you could create your own TextField , see http://jsfiddle.net/fkPzr/ App.TextField = Ember.TextField.extend({

The route i came from, or previous route

▼魔方 西西 提交于 2019-12-22 09:47:00
问题 When i visit one route and then go to another, is where a way to know which route i came from? I tried document.referrer - this doesn't work. Googling hadn't brought any answers either.. I set up this fiddle for example and testing.. 回答1: There is no direct solution using the API. Meaning, this information is not part of the public API. However, you can cache this information yourself. App.set('lastRoutes', []); App.BaseRoute = Ember.Route.extend({ setupController: function() { this._super

The route i came from, or previous route

风格不统一 提交于 2019-12-22 09:46:26
问题 When i visit one route and then go to another, is where a way to know which route i came from? I tried document.referrer - this doesn't work. Googling hadn't brought any answers either.. I set up this fiddle for example and testing.. 回答1: There is no direct solution using the API. Meaning, this information is not part of the public API. However, you can cache this information yourself. App.set('lastRoutes', []); App.BaseRoute = Ember.Route.extend({ setupController: function() { this._super

Ember.js - CircleCI - BrowserStack

烂漫一生 提交于 2019-12-22 09:39:07
问题 I try to connect together our cicleCI with browserstack and run our integration_test and unit tests not only with PhantomJS but on real Firefox and Internet Explorer as well, using Browserstack service. I try to configure browserstack-cli. I can run the test from circleci via tunnel on Browserstack, but never report back to circleci server. Could you please share your experience if you already played with this stack? Thank you very much! 回答1: The solution is to use BrowserStackLocal and

Ember Template Compiler

拈花ヽ惹草 提交于 2019-12-22 09:24:45
问题 I am new to ember.js and javascript frontend MVCs. I am running into: Cannot call 'compile' without the template compiler loaded https://github.com/emberjs/ember.js/issues/10265 So I added: app.import('bower_components/ember/ember-template-compiler.js'); to the top level of my project directory in the Brocfile.js . ember build Future versions of Ember CLI will not support v0.10.33. Please update to Node 0.12 or io.js. version: 0.2.5 A new version of ember-cli is available (0.2.6). To install