Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emberjs event for when model changes

I have an emberjs app that is structured very much like the sample here: https://github.com/tildeio/bloggr-client

The question I have is that when the user clicks on a 'post' on the left, is there any event I can subscribe to in the post view/route/controller that i can tap into? A javascript library I'm using (gridster) requires some javascript to be run as the user switches from post to post. I've tried using didInsertElement but that doesn't seem to fire (using 1.0.5)

like image 461
Ben Avatar asked Jun 11 '13 17:06

Ben


1 Answers

You can observe the PostController's content property. This can be done from anywhere that has access to the PostController. For example, from PostView:

App.PostView = Ember.View.extend({
  templateName: 'post',
  contentDidChange: function() {
    console.log('content changed to: ', this.get('controller.content'));
  }.observes('controller.content')
})
like image 112
Mike Grassotti Avatar answered Sep 30 '22 21:09

Mike Grassotti