How to catch the event of any reorganization DOM inside the template?
I’m doing a guide on bootstrap popover. And need to hide and shows popover if the item it shows hidden.
I create jsbin example
Ember.View.reopen({
popup: null,
renderGuidePopover: function() {
var $el = this.$().find('.' + this.get('controller.actionClass'));
if ($el.length) {
var popover = $el.eq(0).popover({
title : 'Hello',
content : 'I am popup.',
container: 'body',
trigger: 'manual'
}).popover('show');
this.set('popover', popover);
}
}.on('didInsertElement'),
rerendered: function () {
//How catch this when DOM changed?
var $el = this.$().find('.' + this.get('controller.actionClass'));
if (!Em.isEmpty(this.get('popover')) && $el.length) {
$el.popover('destroy');
this.set('popover', null);
}
this.renderGuidePopover();
}
});
App = Ember.Application.create();
App.IndexController = Ember.Controller.extend({
actionClass: 'popup1',
foo: false,
actions: {
toggleFoo: function () {
this.toggleProperty('foo');
},
toggleActionClass: function () {
this.set('actionClass', 'popup2');
}
}
});