jquery datatables modal form -
i have button on form has onclick event handler open modal dialog form:
<button id="btnaddnewrow">add</button> $("#btnaddnewrow").click(function(){ $( "#mydialog-form" ).dialog( "open" ); } );
this adds row current grid , works well. however, thought grid better if had add in grid header div moved this:
"sdom": '<"h"l<"btnaddnewrow">r>t<"f"<"clear">>', "idisplaylength": 25, "fninitcomplete": function () { $("div.btnaddnewrow").html("<div id='btnaddnewrow' class='tblaction'><a href='#'>add</a></div>"); }
the form opens okay no errors in console. when click on "add" in header modal form doesn't open fire ajax that's attached commit button on modal form. errors because nothing has been entered.
i don't understand why behaviour of modal form has changed?
i'm using:
jquery ui - v1.10.2 - 2013-03-14 datatables 1.9.4
looks have use delegation:
$(document).on("click", "#btnaddnewrow", function () { $("#mydialog-form").dialog("open"); });
but aware ids must unique on page context, if have more 1 add button, use class instead.
Comments
Post a Comment