Closed matriphe closed 10 years ago
You can do $("#second").unbind("change");
. Side effect is if you have other change events binded they will be unbinded too.
@tuupola ah! didn't cross my mind! thanks! it's worked!
Got answer from Stackoverflow here: http://stackoverflow.com/a/25912081/3460840
The complete script is:
$(function () {
// remember #second select
var secondCopy = $('#second').clone();
$('#second').chained('#first');
$('#unchain').change(function(){
if ($(this).prop('checked')){
$('#second').chained('#first');
}
else{
$('#first').unbind('change');
// remember selected value:
var value = $('#second').val();
// populate #second select with remembered options
$('#second').html(secondCopy.html());
// set saved value
$('#second').val(value);
}
});
});
I've chained dropdown, and in some event, I want to unchain and rebind chain again? Here some example:
The Javascript will be:
Have tried
$('#second').unbind('chained');
but didn't work.Any suggestion?