ember.js - How to trigger code on view transitions -


i have view this.

app.testview = em.view.extend    templatename: 'test'   modeldidchange: (() ->     # fires twice, need check state make sure doesn't     if @state 'prerender'       # ...do stuff   ).observes('controller.content') 

i want able trigger whenever view changes new model, instance if go route /test/123 /test/456 in app. code above works seems strange. don't think should looking @ state of view. there "correct" way of going this? cant seem find other options. i've tried using on('init') hook, controller appears undefined if use that.

i in route, using setupcontroller hook. called when model changes.

app.testroute = ember.route.extend({   setupcontroller: function (controller, model) {     // call _super default behavior     this._super(controller, model);     console.log('model change:'+model.get('id'));     # ...do stuff   }   }); 

jsbin example: http://emberjs.jsbin.com/potehi/1/edit


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -