I have a country drop down, and on change of it I return a div
containing the same country drop down with additional fields.
I replace this entire div
using the below code. But after the replace of div
is done, the on change
event stops working further. How can I fix this ?
$("#country).on("change", function(){
var str = $("#myform").serialize();
$.ajax({
type: 'POST',
data:str,
url:'../changeme',
success: function(data){
debugger;
var html = $.parseHTML(data);
var arrSelector = $(html).find('div[data-refresh=true]');
var i;
for(i=0;i<arrSelector.length;i++)
{
$('#' + arrSelector[i].id).replaceWith($($(data)).find('#' + arrSelector[i].id));
}
},
done:function(data){
},
error:function(data){
},
complete:function(data){
}
});
});
},