ember.js

Ember.js: Calculate the sum of a property of all child models

只谈情不闲聊 提交于 2020-01-01 02:27:09
问题 My application has the following models: App.Store = DS.Store.extend({ revision: 11, adapter: 'DS.FixtureAdapter' }); App.List = DS.Model.extend({ name: DS.attr('string'), users: DS.hasMany('App.User'), tweetsUnread: function(){ ///////////////////////////////////////// // Code to dynamically calculate the sum // of tweetsUnread property of all // App.User that are related to this list ///////////////////////////////////////// } }); App.User = DS.Model.extend({ screenName: DS.attr('string'),

Ember.js array as model's property

风格不统一 提交于 2020-01-01 01:32:09
问题 Cheers! I have some model, and one attribute of it is an array, but for some reasons (I use mongoDB on the server and it's problem with embedded models and ember-data) I can't do somthing like this: App.Foo = DS.Model.extend({ ... numbers: DS.hasMany('App.Bar') )}; App.Bar = DS.Model.extend({ ... number: DS.attr('number') }); I need something like this: App.Bar = DS.Model.extend({ numbers: DS.attr('array') }); But there is no array type of attributes in ember-data, how to be? 回答1: I found

Ember.js with external handlebars template

蓝咒 提交于 2019-12-31 22:40:33
问题 So, I'm kind of new to Ember.js and it's been a couple of hours since I'm stuck with this. I'm playing with this bloggr client and what I want to accomplish is to load those handlebars templates from external files. The "about" template should render when the user clicks the about page in the panel. Here's the code in short so you dont have to dig that much (I believe it'll be easy for experienced users) Template inside . html as shown in the example <script type="text/x-handlebars" id="about

How do you serve ember-cli from https://localhost:4200 in development

吃可爱长大的小学妹 提交于 2019-12-31 12:52:33
问题 For our authentication to work with our ember app we need to serve the app from a secure url. We have a self signed ssl cert. How do I setup the ember-cli to serve the index.html form a https domain. Cheers 回答1: Also see https://stackoverflow.com/a/30574934/1392763. If you will always use SSL you can set "ssl": true in the .ember-cli file for your project which will result in the ember serve command using SSL by default without having to pass the command line flag every time. By default ember

What is the difference between Adapter and Fixture Adapter and REST Adapter, in ember-data?

别来无恙 提交于 2019-12-31 12:08:30
问题 What is the difference between Adapter and Fixture Adapter and REST Adapter, and when to use each one? 回答1: Use DS.FixtureAdapter (or DS.FixtureAdapter.create() ) when you don't (yet?) care to communicate with a backend, but will store your data as "fixtures" in the client. Once you've declared a model: App.Thing = DS.Model.extend({ name: DS.attr('string'), // ... }); You can define your fixtures: App.Thing.FIXTURES = [ { id: 1, name: '...', // ... }, { id: 2, name: '...', // ... }, ]; And

Super slow preflight OPTIONS in Chrome only

▼魔方 西西 提交于 2019-12-31 11:42:43
问题 I've been struggling recently with a super-weird problem only happening in Chrome: as my API (NodeJS) is on a different subdomain, I need to use CORS to reach it from my front-end (EmberJS). It's working pretty well but I'm very frequently (95% of the time) having very very slow OPTIONS queries, delaying any API calls by about 3 seconds. Most of this time is spent downloading an empty content: It gets even weirder when I'm trying this on another website we made using a similar architecture,

Ember.js & REST API

。_饼干妹妹 提交于 2019-12-31 10:31:08
问题 From all the various examples of Ember.js, I have not been able to figure out if there is a default method in Ember.js to do REST AJAX calls. Many examples build their own interfaces for CRUD operations. I even tried to sift through the code to find any reference to AJAX calls but came up with nothing. So, my question is, is there a default implementation of REST API in Ember.js. If yes, how do I use it? Also if, for a specific application, I want to build custom CRUD methods, where do I plug

Differences between Sproutcore and Ember

懵懂的女人 提交于 2019-12-31 08:05:40
问题 I had selected sproutcore as a framework right before Ember forked from sproutcore. I am left uncertain of which way to go and a bit frustrated in the apparent dilution of efforts caused by the fragmentation - as rarely does that lead to better things. The efforts of Sproutcore 2.0 (now Ember) seemed to be going in the right direction of modularization and reuse of other javasript components (jQuery), however it is really unclear from an outside view why the two efforts had to split... couldn

Differences between Sproutcore and Ember

这一生的挚爱 提交于 2019-12-31 08:04:12
问题 I had selected sproutcore as a framework right before Ember forked from sproutcore. I am left uncertain of which way to go and a bit frustrated in the apparent dilution of efforts caused by the fragmentation - as rarely does that lead to better things. The efforts of Sproutcore 2.0 (now Ember) seemed to be going in the right direction of modularization and reuse of other javasript components (jQuery), however it is really unclear from an outside view why the two efforts had to split... couldn

Ember-data: How do I get an aggregated list of models in a collection on a different collection (@each not working)

吃可爱长大的小学妹 提交于 2019-12-31 05:14:25
问题 I am trying to get an aggregated list of employees . Each organization is a model that hasMany employees . var Organization = DS.Model.extend({ name: attr('string'), employees: hasMany('employee', { async: true }) }); On my controller, I have this property. employees: function(){ var employees =[]; this.get('organizations').forEach(function(organization){ employees.pushObjects(organization.get('employees')); }); return employees; }.property('organizations.@each.employees.isFulfilled') When I