how to replace a core javascript function (elgg.ui.init)?

i'm tweaking the way the error messages are rendered and see that the js code that scripts that process is within ui.js (elgg.ui.init).

i would like to unregister that event and re-register it in my own plugin so that the changes survive core upgrades to elgg.. so far though i haven't succeeded in doing that since i haven't found a js function equivalent to elgg_unregister_event_handler for javascript hooks..

anyone know how to do this without directly changing core files?

thanks

  • I'm not completely sure but I think your handler should overwrite the original hook hander when you call elgg.register_hook_handler().

    Depending on the case you could also use the priority parameter to make sure your handler is called first. And inside your code call event.stopImmediatePropagation() to prevent the other jQuery event handlers from firing (e.g. $('.elgg-system-messages li').live('click'), ...). Then there would be no need to replace elgg.ui.init at all.

     

  • yes, i thought the new definition would over-write the previous one, though that isn't what occured.

    i'll look into those jquery ideas, thanks.