ember.js

ember Uncaught TypeError: undefined is not a function when loading in store

社会主义新天地 提交于 2019-12-18 09:47:33
问题 I'm using ember to display data received from my golang server. The data are in JSON form. so I opened a websocket and tried to push the message received in the store but i got this error: Uncaught TypeError: undefined is not a function this is my app.js: App = Ember.Application.create({ LOG_TRANSITIONS: true }) /******************************* Post Template **************************************/ //Define a route for the template "post" App.Router.map(function() { this.route("post", { path:

Ember async computed property returns undefined

久未见 提交于 2019-12-18 09:12:25
问题 I am attempting to set a property to the value of a model's async, hasMany relationship. But I'm not able to return any value within the then function. App.Athlete = DS.Model.extend({ name: DS.attr('string'), age: DS.attr('number'), splits: DS.hasMany('split', {async: true}), times: DS.hasMany('time', {async: true}), }); App.Time = DS.Model.extend({ athlete: DS.belongsTo('athlete', {async:true}), race: DS.belongsTo('race', {async: true}), time: DS.attr('string'), }); App.Split = DS.Model

How to programatically add component via controller action

不羁的心 提交于 2019-12-18 08:59:03
问题 I have a scenario where I have list of items and each item has a create button. When I click on create, I wanted a component to be appended to the list item. This component uses model data as parameter and also accesses store from within. To access the store in the component I am using targetObject.store The component works well if I add it to the template manually like: {{#each}} <div> blah blah {{my-component data=this.something action="doSomething"}} <button {{action 'add' this}}>Add<

Compile Ember template string and running it programmatically, without an Ember application?

↘锁芯ラ 提交于 2019-12-18 06:59:09
问题 I just want to run the template string against an object and examine the result I have a string that is a template. I've "compiled" it. Now I want to run it against an object and examine the result. But this doesn't work: var template = '<div>{{#each items}}<div>{{item}}</div>{{/each}}</div>'; var compiled = Ember.Handlebars.compile(template); var result = compiled({ items: [1, 2, 3] }); // ERRORS What I want to get is the DOM result of running my compiled string against an object. In other

Create a for loop that will iterate a certain number of times in Ember-CLI

為{幸葍}努か 提交于 2019-12-18 05:52:19
问题 I am in a situation in which I would like to be able to have a component or helper that would allow me to iterate a number of times and output the enclosed block each time. Something like this: {{#incremented-for 2}} block to output {{/incremented-for}} I tried to set this up as a component, but was not able to figure out a way to make it work. I also tried to set it up as a helper, and was able to find some code that seems like it should work: export function incrementedFor(n, block) { var

Ember template not updating from arraycontroller

末鹿安然 提交于 2019-12-18 05:25:26
问题 In my app, a user can enter a description of a friend or upvote a description that is already present. Both methods (createDescription and upvoteDescription) persist in the database. upvoteDescription changes the DOM, but createDescription does not. It may be because I'm passing a parameter in the model, but I can't get around that -- the api needs it. //descriptions route App.DescriptionsRoute = Ember.Route.extend({ ... model: function () { var store = this.get('store'), friend = this

Transform JSON to an appropriate format for RESTAdapter EmberJS

旧街凉风 提交于 2019-12-18 05:04:09
问题 I receive a JSON from our API that has the following format [ { "id": 45, "name": "Pasta", "_order": 0, "is_hidden": null, "is_list": false }, { "id": 46, "name": "Salads", "_order": 1, "is_hidden": null, "is_list": false }, { "id": 47, "name": "Dessert", "_order": 2, "is_hidden": null, "is_list": false } ]; I see that it has invalid format for standard RESTAdapter and I need to put the name of the model first. In my example it should probably be like: { "category": [ { "id": 45, "name":

Rails RoutingError (No route matches [OPTIONS]

最后都变了- 提交于 2019-12-18 04:35:17
问题 I'm creating a rest api using rails and making calls from a remote ember app using ember data. I'm getting this routing error on what should be a GET request. How do I create an OPTIONS method and will I have to do this for every resource? I can provide code snippets if needed. 回答1: Installing and configuring this gem should allow your Rails application to properly process the options request caused by CORS: https://github.com/cyu/rack-cors 来源: https://stackoverflow.com/questions/25588699

Does Ember routing fall back to using a hash if browser doesn't support the History API?

主宰稳场 提交于 2019-12-18 04:09:31
问题 Ember documentation states that it can be set to use the History API for routing rather than hash-based fragments by using: App.Router.reopen({ location: 'history' }); But I can find no mention of what will happen if a browser doesn't support the History API. Will it fall back to using a hash like History.js? If not, should I check for History API support and switch history implementation to hash if it isn't supported? 回答1: There doesn't seem to be any History API support detection in the

Ember CLI and ASP.NET

旧巷老猫 提交于 2019-12-18 03:22:16
问题 I've successfully used the EmberJS JavaScript framework with an ASP.NET web application, by referencing ember.js file. I'm under the impression that Ember-CLI is the way Ember will be heading in future versions. If this is correct, what's the appropriate way to keep using Ember going forward? Does it make sense to use Ember-CLI with ASP.NET, or is the assumption that the client is only ever static HTML and CSS/JS that calls back to server-side code (eg. WebAPI)? 回答1: Ember-Cli is just the