ajax - JQuery: Dynamic page content and attaching button click -
i have grid when click on pager link html return server side ajax call , new grid html getting append in div. new html content has button has class called edit-user
.
so wrote code attach jquery click button adding in page dynamically.....but in case not working.
$(function () { $('#gridcontent').on('click','.edit-user', function () { var tr = $(this).parents('tr:first'); $(tr).addclass('editing'); if ($(tr).find("td:nth-child(2)").hasclass('padon')) { $(tr).find("td:nth-child(2)").removeclass("padon"); $(tr).find("td:nth-child(3)").removeclass("padon"); $(tr).find("td:nth-child(4)").removeclass("padon"); $(tr).find("td:nth-child(5)").removeclass("padon"); } $(tr).find("td:nth-child(2)").addclass("padoff"); $(tr).find("td:nth-child(3)").addclass("padoff"); $(tr).find("td:nth-child(4)").addclass("padoff"); $(tr).find("td:nth-child(5)").addclass("padoff"); tr.find('.edit-mode, .display-mode').toggle(); $(tr).find("input[id*='txtfirstname']").focus(); return false; });
i using jquery file version v1.10.2. looking , suggestion made mistake new button has not getting attached jquery button click event. thanks
try following. hope help.
$('body').on('click','.edit-user', function () { //your code });
Comments
Post a Comment