Skip to content

Instantly share code, notes, and snippets.

@Piioo
Created June 2, 2014 10:01
Show Gist options
  • Save Piioo/d788f519eecd5259c398 to your computer and use it in GitHub Desktop.
Save Piioo/d788f519eecd5259c398 to your computer and use it in GitHub Desktop.
Global Trigger
Discourse.AdsenseTopicAfterPostsView = Discourse.AdsenseView.extend({
templateName: "topic_after_posts",
location: null,
init: function(){
var self = this;
var post_number = this.get('post_number');
if ($.inArray(post_number, [1,3,8]) != -1 ) {
this.set('location', "topic_after_" + post_number + "_post");
$('body').on('didInsertElement'+post_number, function(){
self.didInsertElement();
})
}
this._super();
}
});
Ember.CloakedView.reopen({
didInsertElement: function(){
this._super();
var post = this.get('containedView.post');
if(post) {
$('body').trigger('didInsertElement'+post.get('post_number'));
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment