Reputation: 91
I need to unbind a click event then after its fired I need to bind it again
Here's my script
$(function() {
$('.bundle').unbind().click(function() {
var codeList = "641351,641251,641253";
$.fn.addBundle(codeList);
});
$('.bundle').bind().click(function() {
var codeList = "641351,641251,641253";
$.fn.addBundle(codeList);
});
});
It's not working properly, can anyone let me know what I've don't wrong.
Thanks
Upvotes: 0
Views: 871
Reputation: 17927
you should unbind and bind the click event like this:
$(".bundle").unbind("click")
.bind("click", function(){
// do what you need onclick here
});
As suggested in the bind() documentation
, you should use on()
and off()
instead of bind()
and unbind()
:
$(".bundle").off("click")
.on("click", function(){
// do what you need onclick here
});
See a working example here
Upvotes: 1