jquery - Force second handler to be executed, bind with on -


i have written template parser in javascript. renders 'project' calendar , appends click handler. when click project container starts loading project content in other window. far good. @ 1 point need overwrite click handler , replace one. sounds easy @ first, program uses mix of push , polling services , project has been rendered several times minute (it complete replaced, @ least in first iteration).

the normal click handler added using jquery's click() method. special click handler added using jquery's on() method, since projects have clickable new handler. now, every time project re-rendered click handler appended , executed before handler added on :(

i could set flag @ templater can decide handler should add project, interfere our program paradigms using each module must complete executable without interacting other modules.

any suggestions? prioritize handlers?

you can remove previous click hander before binding new one.

$yourobject.off('click');            .on('click', function(event){                //do sth             }); 

http://api.jquery.com/off/

if have more 1 click, , want unbind of them use event namespacing.

binding:

$yourobject.on('click.module-name'); 

unbinind click event handlers namespace:

$yourobject.off('click.module-name'); 

unbinding event handlers namespace:

 $yourobject.off('.module-name'); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -