Run JS function when block has been deleted
Permalink
Hi all,
I am wondering if there is a way to hook into the js delete block function. For example when a block is deleted the update notification appears in the top right of the screen. I'd like to run my own js function at the same times as when the above notification message appears.
Any help would be greatly appreciated.
Cheers,
Mat
I am wondering if there is a way to hook into the js delete block function. For example when a block is deleted the update notification appears in the top right of the screen. I'd like to run my own js function at the same times as when the above notification message appears.
Any help would be greatly appreciated.
Cheers,
Mat
hi @JohntheFish
Thanks for the quick response much appreciated. Not following unfortunately. This is what I've come up with:
But I get the below error:
Uncaught TypeError: Object function () {
redirect_old_handler();
alert('test');
} has no method 'hud'
Thanks,
Mat
Thanks for the quick response much appreciated. Not following unfortunately. This is what I've come up with:
<script> $(function () { var redirect_old_handler = ccmAlert; var redirect_new_handler = function() { redirect_old_handler(); alert('test'); }; ccmAlert = redirect_new_handler; }); </script>
But I get the below error:
Uncaught TypeError: Object function () {
redirect_old_handler();
alert('test');
} has no method 'hud'
Thanks,
Mat
My mistake, ccmAlert() is an object with a couple of methods. You need to apply the trick to the individual method ccmAlert.hud (or maybe ccmAlert.notice).
You can see the source for what you are intercepting in the core file js/legacy_dialog.js
You can see the source for what you are intercepting in the core file js/legacy_dialog.js
http://www.concrete5.org/documentation/how-tos/developers/subvert-t...
Applying a similar subversion to the global js function ccm_deleteBlock() would probably be more robust as it would not be susceptible to the whims of any changes to notification processing, but the script would run when the delete started, not when it had completed.
In c5.7 I suspect that both of the above could break because the ccm.app javascript is being substantially redeveloped.
In either case the script that inserts the subverted function would have to be loaded and run after ccm.app.js is loaded.