ember.js

Ember.js wizard control

你离开我真会死。 提交于 2019-12-19 10:07:09
问题 I have an ember.js wizard control with a number of steps. An ember model object has its various properties set at each stage of the wizard. The only way I can see of changing the view is to use the linkTo helper like this: {{#linkTo steps.two model}}Step 2{{/linkTo}} But this is no good to me as I will need each step that I linkTo to to be a dynamic route: @resource "steps", -> @route "one", {path: 'one/:model_id'} @route "one", {path: 'two/:model_id'} #etc. The dynamic route is no good

Adding headers after RESTAdapter initialization

早过忘川 提交于 2019-12-19 09:16:14
问题 I am trying to add an Authorization header to my adapter's request after the adapter has been initialized and used. I can add headers in a static way at the time I create my ApplicationAdapter , but I can't seem to get it use the headers in subsequent REST calls. I am trying this: var auth= "Basic " + hash; App.ApplicationAdapter.reopen({ headers: { Authorization: auth } }); I have debugged RESTAdapter in the ajax method, and the test for adapter.headers is always undefined . 回答1: The

Multiple dynamic segments in ember.js

£可爱£侵袭症+ 提交于 2019-12-19 09:06:22
问题 I currently have my routes defined like this: App.Router.map(function() { this.resource('players', { path: ':page_id' }, function() { this.resource('player', { path: ':player_id' }); }); }); The idea is that I have a list of player names on the left. The player names displayed depend on the page_id. On the right, I display a single player and all its information based on the player_id. The thing is, both are independent, meaning that I could be on the third player page, while displaying the

After localStorage.clear() or deleteRecord() in my Ember.js app, local storage data are resurrected

我是研究僧i 提交于 2019-12-19 08:57:20
问题 I'm observing a data resurrection after localStorage.clear() or deleteRecord() (jsbin example) is called in my ember app. Follow these steps to replicate the problem: Open up chrome web dev --> Resources --> Local Storage --> "http://jsbin.com" Add some orgs on this page and observe that they are added to local storage Click on "Clear local storage" (case 1) or "Delete Org data" (case 2) and observe that the local storage is cleared. Do not refresh the page. (Data still remain on the page but

Ember.js: Observing array property using @each doesn't work

拈花ヽ惹草 提交于 2019-12-19 08:12:58
问题 My understanding is that observing for '@each' means that I'm observing any change to any property in an array, but it doesn't seem to work. For example: App.ArrayProxy = Ember.ArrayProxy.extend({ i: 0, foo: function(){ console.log('foo called'); return ++this.i; }.property('content.@each') }); I've also tried .property('@each') instead of .property('content.@each') with equally disappointing results. Here is a jsbin that demonstrates: http://jsbin.com/hagar/5/edit In the demo, changing the

Is there any way to convert Ember Object into plain javascript object?

夙愿已清 提交于 2019-12-19 05:17:15
问题 I could not find any way to accomplish the task of such conversion as I could not find any means of getting Ember.js properties for the object. Ember.keys returns only the properties I set in create or with get and the properties declared in Ember.extend do not show up there. I use such properties to set up default values (e.g. [] for array properties) 回答1: Here is my dirty workaround var newModel = JSON.parse(JSON.stringify(model)); 回答2: I would do something similar to the person above, but

Advantages of a separate REST backend API?

与世无争的帅哥 提交于 2019-12-19 04:33:11
问题 Context: I'm a beginner programmer, self taught in the hope of making a SPA. I've started with JavaScript, Jquery, PHP and MySQL, and now feel pretty confident with all. I've started with Ember, and am now moving away from having a PHP API to Node. Which has then brought me closer to Meteor... I'm aware I'll need to use Mongo instead, but having an integrated front and back seems to be sensible and have some advantages. So my question is what are the advantages of having a separate REST

ember data serializer data mapping

帅比萌擦擦* 提交于 2019-12-19 04:08:11
问题 I'm using ember & ember-data to try and consume a json feed from the server. Here is my code: App = Ember.Application.create(); DS.RESTAdapter.configure( "plurals", { category: 'categories' } ); App.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter.create({ url: 'app' }) }); App.Router.map(function(){ this.resource('categories'); }); App.CategoriesRoute = Ember.Route.extend({ model: function() { return App.Category.find(); } }); var attr = DS.attr; App.Category = DS.Model.extend

Square brackets surrounding parameter in function definition

寵の児 提交于 2019-12-19 01:15:05
问题 I came across the following code in the Ember CLI website: export default Ember.Helper.helper(function([value]) { return value.toUpperCase(); }); What confuses me is the square brackets surrounding the value parameter. I can understand it in a function call, but why in function definition? 回答1: This is all very surprising to me, but it appears to be valid javascript, according to the ECMAScript 2017 language specification, the formal parameter in a function declaration can any "binding

Square brackets surrounding parameter in function definition

↘锁芯ラ 提交于 2019-12-19 01:14:35
问题 I came across the following code in the Ember CLI website: export default Ember.Helper.helper(function([value]) { return value.toUpperCase(); }); What confuses me is the square brackets surrounding the value parameter. I can understand it in a function call, but why in function definition? 回答1: This is all very surprising to me, but it appears to be valid javascript, according to the ECMAScript 2017 language specification, the formal parameter in a function declaration can any "binding