i'm bind a dropdown
("#dropdownlist").change(function(){});
i'm calling the above code so many time.
how can i unbind this event before binding it each time....?
i'm bind a dropdown
("#dropdownlist").change(function(){});
i'm calling the above code so many time.
how can i unbind this event before binding it each time....?
Use following logic:
var f = function () {
}
$('#xx').bind('change', f); // for bind function f
$('#xx').unbind('change', f); // for unbind unbind function f
Additionally jQuery supports namespaces.
For example say you have change handlers that do validation and change handlers that do help text hovering.
You could register:
$("#foo").bind("change.validation", doValidation() );
and
$("#foo").bind("change.helptext", toggleHelptext() );
and then you can unbind a specific set before re-adding validation, e.g.
$("#foo").unbind("change.validation");
$("#foo").bind("change.validation", doValidation() );
HTH Alex