topics: improve handling topics without callbacks subscribed
This commit is contained in:
parent
a03e4a88f9
commit
a537335516
4 changed files with 13 additions and 4 deletions
|
|
@ -384,7 +384,7 @@ $(document).ready(function() {
|
|||
|
||||
tr[0].scrollIntoView();
|
||||
|
||||
$.Topic('/ui/plugins/code/anchor_focus').prepare({
|
||||
$.Topic('/ui/plugins/code/anchor_focus').prepareOrPublish({
|
||||
tr:tr,
|
||||
remainder:remainder});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ var injectInlineForm = function(tr){
|
|||
}
|
||||
}, 10);
|
||||
|
||||
$.Topic('/ui/plugins/code/comment_form_built').prepare({
|
||||
$.Topic('/ui/plugins/code/comment_form_built').prepareOrPublish({
|
||||
form:_form,
|
||||
parent:_parent}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,14 @@ jQuery.Topic = function (id) {
|
|||
this.unhandledData.push(arguments[i]);
|
||||
}
|
||||
},
|
||||
prepareOrPublish: function(){
|
||||
if (callbacks.has() === true){
|
||||
this.publish.apply(this, arguments);
|
||||
}
|
||||
else{
|
||||
this.prepare.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
processPrepared: function(){
|
||||
var data = this.unhandledData;
|
||||
this.unhandledData = [];
|
||||
|
|
@ -40,7 +48,8 @@ jQuery.Topic = function (id) {
|
|||
}
|
||||
},
|
||||
subscribe: callbacks.add,
|
||||
unsubscribe: callbacks.remove
|
||||
unsubscribe: callbacks.remove,
|
||||
callbacks: callbacks
|
||||
};
|
||||
if (id) {
|
||||
topics[id] = topic;
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ ${pyramid_render(config['template_hooks'].get('plugin_init_template'),
|
|||
% endif
|
||||
% endfor
|
||||
<script>
|
||||
$.Topic('/plugins/__REGISTER__').publish({});
|
||||
$.Topic('/plugins/__REGISTER__').prepareOrPublish({});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue