wie " Ereignis hinzufügen Klicken Sie für dynamischen tr in Tabelle

ich habe eine html Tabelle und fügen Sie in der Tabelle Zeile in der Laufzeit. ich möchte hinzufügen, um die neue tr(dynamic tr) hinzufügen ClickEvent
Schreibe ich diesen code, aber es ist nicht die Arbeit

$("#GridView1 tbody tr").klicken Sie(function (e) {

                var id = $(this).find(".lbl").text();
                workOrderId = id;
                // $("#gridtbl tr").remove();
                $.ajax({
                    url: "PublicHandler.ashx",
                    contentType: "application/json; charset=utf-8",
                    data: { workOrderId: id },
                    success: function (data) {
                        var grd = $("#gridtbl");
                        $.each(data, function (i, b) {
                            var str = "<tr>";
                            str += "<td style='display: none;'>" + b.WorkId + "</td>";
                            str += "<td>" + b.WorkName + "</td>";
                            str += "<td>" + b.SectionName + "</td>";
                            str += "<td>" + b.SectionSupervisor + "</td>";
                            if (b.RequestCount == null) {
                                str += "<td>" + " " + "</td>";
                            } else {
                                str += "<td>" + b.RequestCount + "</td>";
                            }

                            str += "<td>" + " " + "</td>";

                            str += "</tr>";
                            $(str).click(function () {
                                alert("hiiiiiiiiiii");

                            }).end().appendTo("#gridtbl tr");
                            //grd.append(str);

                        });
                    },
                    dataType: "json"

                });
                popup(e);
            });
Sie verwenden müssen .on() (jQuery 1.7+) oder .delegate()

InformationsquelleAutor Pouya | 2011-12-07

Schreibe einen Kommentar