I have a web page with a Select option and FORM, When a user changes selection, My jquery script function will dynamically do ajax POST to replace original form with different form (new form elements).
But i noticed that Click handler ($(button).click() Event) is not working on the newly generated form. Please assist on this.
Is this a known problem in Jquery ??.
<select id=choice><option>....</select>
<div class=mytable>
<form id='dataform-10'>
.....
<button id="edit-10"></button>
</form>
<div>
<script>
$(function(){
$("#choice").change(function(){
$.get('/portal/go?id='+this.value, function(data, status){
//$(".mytable").hide();
$(".mytable").html(data);
$(".mytable").show();
});
});
});
</script>
<script>
$('[id^=edit]').on("click",function(e) {
e.preventDefault();
var num = this.id.slice(5);
var fdata = $('#dataform-'+num).serialize();
$.post('/portal/update', fdata, function(data, status){
alert(data);
});
});
</script>