ember.js

calling method from action of controller in emberjs

我怕爱的太早我们不能终老 提交于 2019-12-20 16:50:09
问题 for example i have a controller like this : App.theController = Ember.ArrayController.extend({ methodA:funtcion() {}, actions: { methodB:function(){}, methodC:function(){} } }); my questions is : How can methodB call methodC How can methodA call methodB 回答1: You have to use this.send([methodName]) in order to get your methods called correctly: var App = Ember.Application.create({ ready: function() { console.log('App ready'); var theController = App.theController.create(); theController.send(

calling method from action of controller in emberjs

久未见 提交于 2019-12-20 16:49:13
问题 for example i have a controller like this : App.theController = Ember.ArrayController.extend({ methodA:funtcion() {}, actions: { methodB:function(){}, methodC:function(){} } }); my questions is : How can methodB call methodC How can methodA call methodB 回答1: You have to use this.send([methodName]) in order to get your methods called correctly: var App = Ember.Application.create({ ready: function() { console.log('App ready'); var theController = App.theController.create(); theController.send(

How to bind content with JSON in Ember.js

最后都变了- 提交于 2019-12-20 14:38:15
问题 All the examples are using fixed data source in the arraycontroller.content, while I am using dynamic data source which is generated from anther web service and returns a JSON, it won't create an object that I declared in Ember, here is the code sample: ET.AppYear = Ember.Object.extend({ text:null, value:null }); ET.EmailTypes = Ember.Object.extend(); ET.appYearController = Ember.ArrayController.create({ content: [], loadYears: function (year) { if (year != null) { for (var i = -5; i < 5; i++

How to bind content with JSON in Ember.js

孤街浪徒 提交于 2019-12-20 14:37:25
问题 All the examples are using fixed data source in the arraycontroller.content, while I am using dynamic data source which is generated from anther web service and returns a JSON, it won't create an object that I declared in Ember, here is the code sample: ET.AppYear = Ember.Object.extend({ text:null, value:null }); ET.EmailTypes = Ember.Object.extend(); ET.appYearController = Ember.ArrayController.create({ content: [], loadYears: function (year) { if (year != null) { for (var i = -5; i < 5; i++

Bootstrap Popovers with ember.js template

♀尐吖头ヾ 提交于 2019-12-20 14:05:27
问题 I'm trying to use Bootstrap Popover with EmberJS, so that the content of the popover will be a ember/handlebars template (with binding etc). How can this be done? (Ember 1.0.0-rc2) 回答1: Here is a working example for an ember bootstrap popover (see http://jsfiddle.net/72fSd/): App.Popover = Ember.View.extend({ parentSelector: '', contentSelector: '', didInsertElement: function () { var self = this; $(self.parentSelector).popover({ html: true, content: function() { var $content = $(self

Ember CLI Live Reload Not Working

笑着哭i 提交于 2019-12-20 12:36:29
问题 I've seen other similar questions here and here but neither of those worked for me. I'm on a mac and simply installed ember cli using npm and I thought it would work out of the box. Here is the server output: version: 0.1.4 Could not find watchman, falling back to NodeWatcher for file system events Livereload server on port 35729 Serving on http://0.0.0.0:4200/ Build successful - 2456ms. Slowest Trees | Total -------------------------------+---------------- EsnextFilter | 877ms TreeMerger |

Display online and offline (e.g. airplane) mode in an Ember.js App

那年仲夏 提交于 2019-12-20 12:33:37
问题 Can an Ember app be aware of the network status? If yes: How can I get the information if the app has access to the internet or not? I'd like to switch GUI elements depending on the network accessibility. index.html <script type="text/x-handlebars"> Status: {{#if isOffline}} Offline {{else}} Online {{/if}} <hr> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="index"> <h2>Hello World</h2> </script> app.js App = Ember.Application.create(); 回答1: The short: Since you

Delete associated model with ember-data

蓝咒 提交于 2019-12-20 12:31:59
问题 I have two models: App.User = DS.Model.create({ comments: DS.hasMany('App.Comment') }); App.Comment = DS.Model.create({ user: DS.belongsTo('App.User') }); When a user is deleted, it also will delete all its comments on the backend, so I should delete them from the client-side identity map. I'm listing all the comments on the system from another place, so after deleting a user it would just crash. Is there any way to specify this kind of dependency on the association? Thanks! 回答1: I use a

Is it possible to use function in Handlebars #if?

女生的网名这么多〃 提交于 2019-12-20 12:07:04
问题 I have a controller object that's like: MyApp.objController = Ember.ArrayController.create({ init: function(data) { data.isValid = function() { return (data.validity === "valid"); } this.pushObject(MyApp.MyObj.create(data)); } }); My view is like: {{#each MyApp.objController}} {{#if isValid}} <some markup> {{else}} <some other markup> {{/if}} {{/each}} I was assuming that the if conditional in Handlebars accepts both values and functions, but this doesn't seem to be the case. Is it actually

Dynamically choosing a view at runtime with Ember + Handlebars

好久不见. 提交于 2019-12-20 11:28:14
问题 I am using Ember, Ember Data, and Handlebars to display a timeline with a number of different types of models. My current implementation, though functioning properly, seems like it could be drastically improved with a convention and a helper. However, I can't figure out how to use already defined templates. This is what I have: {{#view App.AccountSelectedView contentBinding="App.selectedAccountController.everythingSorted"}} {{#with content}} <ol class="timeline"> {{#each this}} {{#is