ember.js

Ember - Sort Model after findAll

一个人想着一个人 提交于 2019-12-24 10:35:14
问题 I'm using Emberfire in my app, and I'm trying to findAll stats, and then sort that model by a key, like in the following example. But, when I sort this way I lose the ability to see real time updates in my template and I have to reload the page to see the new/updated data in the view. model() { return this.store .findAll('stats', { reload: true, backgroundReload: true }) .then(stats => stats.sortBy('date')); } 回答1: You have to define a computed property at your controller or a component,

Emberjs / ember-browserify : “X is not a constructor”?

血红的双手。 提交于 2019-12-24 10:27:00
问题 This question relates to my earlier question. Trying to use howler.js (https://github.com/goldfire/howler.js#documentation) in a Controller. There is no addon for Howler but it exists as a npm package. I've followed the instructions to use ember-browserify and then started the ember dev server ( ember s ). The import looks like this : import Howl from "npm:howler"; I've also tried this : import {Howl as Howl} from "npm:howler" ; and this : import {Howl} from "npm:howler" ; In all cases when I

How to get object at index in Array Controller within view?

♀尐吖头ヾ 提交于 2019-12-24 09:59:40
问题 I have a view that has an Array Controller as a property. I would like to get an element at an index within the view. view: {{ App.array.firstObject }} works but: {{ App.array.objectAt(1) }} doesn't work. I can't iterate in my case. So is there a way to do that? 回答1: Does {{App.array.[1]}} work for you ? 来源: https://stackoverflow.com/questions/11724272/how-to-get-object-at-index-in-array-controller-within-view

How to create a tree of promises?

两盒软妹~` 提交于 2019-12-24 09:57:36
问题 I'm trying to create a tree of promises in Ember. return this.store.find('session', 'session').then(function(session) { if (session.get('isEmpty')) { return this.store.createRecord('session').save().then(function(session) { session.set('id', 'session'); return session.save(); }.bind(this)); } else { return session; } }.bind(this), function(session) { return this.store.createRecord('session').save().then(function(session) { session.set('id', 'session'); return session.save(); }.bind(this)); }

ember-data - loading data for a menu - best approach

风格不统一 提交于 2019-12-24 09:25:42
问题 I have a list of categories that are loaded on the application route: ApplicationRoute = Em.Route.extend({ model: function() { return Em.RSVP.hash({ collections: this.store.find('collection'), categories: this.store.find('category'), links: this.store.find('link') }); } }); This triggers the categories index action on the server, as expected. I am doing this because I need to load a list of categories for a menu. I also have a category route: Router.map(function() { this.route('category', {

How do I install bootstrap 4 template to Ember web project?

北城余情 提交于 2019-12-24 08:59:20
问题 This is a continuation of another post I have posted: click here I have downloaded the INSPINIA admin theme, which is based off twitter bootstrap. It contains pre-created projects for most web-ui frameworks, except Ember. Steps taken so far: Installed ember-boostrap Installed SASS pre-processor Copied the *.scss files into the app\styles folder The app.scss file looks as follows: app\styles\app.scss @import "ember-bootstrap/bootstrap"; @import "style"; The Ember-Cli-Build.js file is as

Emberjs - unable to query for embedded model or association

你离开我真会死。 提交于 2019-12-24 08:58:56
问题 A small portion of this fiddle: http://jsfiddle.net/v2t67/ is displayed in my question, but my problem is that i am unable to query for the json of the child model ie the comment model. As of now, i can access the parent object (Post Model) from chrome developer console using the queries below and from the result that contains the parent object, in the console, i can click on it and i will see the embedded comments as shown in this screenshot: http://imgur.com/3WL4I. So how will query for the

Does it make sense to use ObjectController and ArrayController together?

吃可爱长大的小学妹 提交于 2019-12-24 08:58:29
问题 I have a list of object, stored in an arrayController and rendered on the view using the #each macro {{#each item in controller}} {{view App.ItemView}} {{/each}} Each item view has class name binding that depends on the user action. For exemple : App.ItemView = Ember.View.extend { classNameBindings: ['isSelected:selected'] } isSelected depends on the state of each Item : I have to store the selected item somewhere, and compare it to the new selected item if a click event is triggered. The

EmberJs: render template inside Handlebars-helper

巧了我就是萌 提交于 2019-12-24 08:57:53
问题 I have this situation in which I have the template-name stored in a variable. I noticed that if you have for example var config = { view: "PeopleView", .... } ; that you can't do {{view App[config.view]}} If this is possible, I'm still interested in the solution! Anyway, I decided to fix this with a Handlebars helper: {{setVariableView config}} ... Ember.Handlebars.registerBoundHelper('setVariableView', function(value, options) { return App[value.view].create(value) ; // <-- this doesn't work

How to update model with new records in EmberJS

左心房为你撑大大i 提交于 2019-12-24 08:51:14
问题 I have a table that gets populated based on records from a rest API. All of this works fine. Now I want to add some buttons on top of the table. When these buttons are clicked, the api is called again but this time with some parameters. Then I want the table to be updated with these new records. How can I achieve this? My template looks like this: <div id="myEmberElement"> <script type="text/x-handlebars" id="posts"> <div id="controls"> <a href="#" id="mostrated">MostRated</a> <a href="#" id=