Q:

jQuery override an on() event with another on() event

I have 2 files, file 1 (head.tpl) contains this default function operation
$(document).on("click", "#blackout", function(){
    closeSkyBox();
});

That is the default operation I want to run, and it works.
On my second page, I would like to override the operation that is in head.tpl with this:
$(document).on("click", "#blackout", function(){
    closeSkyBox(function(){
        pev_for_country = '';
    });
});

So, now when I test the code, each one runs, so If I were to place an alert (for testing reasons) I get two alert boxes. How can I make it so only the one in the second page runs, and the one in head.tpl is disabled. Then when I don't override it say on a third page, the one in head.tpl runs?

A:

Looks like you're looking for jQuery's .off
$(document)
    .off('click', '#blackout')
    .on('click', '#blackout', function () {
        // ...
    });

