How to override JS function?

Last modification: 2013-09-30 17:43:00

Let say you want to override some JS function. You can do that in the following workflow.

  • There is example in the extension folder. Basically there are two important files
    • customstatus/design/customstatustheme/tpl/pagelayouts/parts/page_head_js_extension.tpl.php
    • customstatus/design/customstatustheme/js/custom.js
  • So as we have a file where we can write our own JS. How to override default function? Let say we want to show alert to user then he decied to do not send transcript to his e-mail. Like in our system this executes. 

 

this.cancelcolorbox = function(){
        $.colorbox.remove();
    };

Our custom.js file content should look like.

lhinst.cancelcolorbox = function(data){

if (confirm('Are you sure')){
    $.colorbox.remove();
}

};

So this way we have overrided default behaviour without changing kernel.

Support project

Developing application takes a lot of time. You can support application by donating. There is no company behind this application and it takes away my free time. Every donation matters and does not matter how small it is!


Paypal, one time donation
Monthly donation
Bitcoin
Skrill
remdex@gmail.com


comments powered by Disqus