ember.js

Detect route transitions in EmberJS 1.0.0-pre.4

大憨熊 提交于 2019-12-31 02:54:20
问题 I am trying to detect when a route transition occurs. I've located this code snippet inside the latest version of Ember ( v1.0.0-pre.4 ) that handles the transitions: didTransition: function(infos) { // Don't do any further action here if we redirected if (infos[infos.length-1].handler.transitioned) { return; } var appController = this.container.lookup('controller:application'), path = routePath(infos); set(appController, 'currentPath', path); this.notifyPropertyChange('url'); if (get(this,

Ember-Data: Accessing a list of sideloaded resources?

狂风中的少年 提交于 2019-12-31 01:51:08
问题 I have some JSON that has this structure in the /documents path (the IDs are UUIDs): { "tags": [ { "id": "a33fc396-2428-11e3-8eeb-0800270f33f4", "name": "test" } <more tags not shown> ], "documents": [ { "id": "c41460fa-2427-11e3-8702-0800270f33f4", "name": "file.txt", "tag_ids": [ "a33fc396-2428-11e3-8eeb-0800270f33f4" ] } <more documents not shown> ] } We see that the Tag resource is sideloaded. I'm using ember-data to load the JSON using these routes: App.Router.reopen location: 'history'

get action target element in ember

为君一笑 提交于 2019-12-31 01:44:32
问题 How can I get the target element's object on which a click event was fired. For eg, if I have a template like: <table> <tr> <th {{action "someAction"}} >Type</th> </tr> </table> and in my controller I have corresponding action defined like: action:{ someAction : function(){ //get the th element object } } It seems like event object is not passed, because I had tried action:{ someAction : function(event){ //event is undefined! } } UPDATE : Thanks Márcio and Jeremy. I've now got a working

add/delete items from Ember Data backed ArrayController

不打扰是莪最后的温柔 提交于 2019-12-30 17:59:53
问题 I'm using an ArrayController in my application that is fed from a Ember Data REST call via the application's Router: postsController.connectOutlet('comment', App.Comment.find({post_id: post_id})); For the Post UI, I have the ability to add/remove Comments. When I do this, I'd like to be able to update the contentArray of the postsController by deleting or adding the same element to give the user visual feedback, but Ember Data is no fun: Uncaught Error: The result of a server query (on App

Emberjs - Connecting an {{ input }} filter bar with my list of Objects. As I type, the list filters

会有一股神秘感。 提交于 2019-12-30 12:22:16
问题 I am trying to incorporate this working example http://jsbin.com/AViZATE/37/edit of a filtering search bar with my own project. The search bar does not seem to be connected to my list of objects. :( Let me show you what I've done. App.RecordCategoriesController = Ember.ArrayController.extend({ searchResult: function(){ var searchTerm = this.get('searchTerm'); var regExp = new RegExp(searchTerm,'i'); this.get('model').set('content',this.store.filter('recordCategory',function(item){ return

Ember Simple Auth custom authenticator

我只是一个虾纸丫 提交于 2019-12-30 10:29:08
问题 I've been trying to create a session.currentUser property with an id , email , and points properties. I'm referencing Custom authenticator with Ember simple auth + Ember CLI and How to store the user in a session, but I just can't figure out how the pieces fit together. I'm using Ember CLI. In my index.html , I have: window.ENV['simple-auth'] = { authorizer: 'simple-auth-authorizer:devise', session: 'session:custom' }; In initializers/custom-session.js , I have: import Session from 'simple

Define application template in Ember.View in the most recent Ember.js Build

微笑、不失礼 提交于 2019-12-30 10:05:14
问题 I recently upgraded to the most recent Ember.js build (built from the GitHub page.) When using the new router, does this no longer work? App.ApplicationView = Ember.View.extend({ template: Ember.Handlebars.compile("Hello") }); I much prefer to define my templates in my js file rather than index.html. I believe it is much cleaner. However, the above does not render! Any suggestions? Thanks! 回答1: For Ember 1.0, templates should be defined in index.html or in separate files that are provided to

How to listen to a paste event on a textarea in emberjs

五迷三道 提交于 2019-12-30 09:38:21
问题 I have a component that holds the following template: <div> {{textarea value=content autofocus="autofocus"}} <button {{action 'cancel'}}>cancel</button> </div> How can I listen to a paste event on this textarea in my component? I tried to create a paste action but this doesn't seem to work: App.EditableTextComponent = Ember.Component.extend({ templateName: 'components/editable-text', actions: { paste: function() { console.log(arguments); } } }); 回答1: As @wojciech-bednarski suggest in his

How to listen to a paste event on a textarea in emberjs

孤街醉人 提交于 2019-12-30 09:36:27
问题 I have a component that holds the following template: <div> {{textarea value=content autofocus="autofocus"}} <button {{action 'cancel'}}>cancel</button> </div> How can I listen to a paste event on this textarea in my component? I tried to create a paste action but this doesn't seem to work: App.EditableTextComponent = Ember.Component.extend({ templateName: 'components/editable-text', actions: { paste: function() { console.log(arguments); } } }); 回答1: As @wojciech-bednarski suggest in his

Is there a way to pass an array to currentWhen in EmberJS?

微笑、不失礼 提交于 2019-12-30 08:32:21
问题 I'm trying to make a link stay 'active' on multiple routes, such as /#/users and /#/user. Any ideas? 回答1: You can reopen Ember's LinkView and do something like this (allows currentWhen to contain space delimited values) Ember.LinkView.reopen({ active: function() { // we allow link-to's currentWhen to specify multiple routes // so we need to check each one of them var loadedParams = Ember.get(this, 'loadedParams'); var currentWhen = this['current-when'] || this.currentWhen; currentWhen =