0
追加行我已經使用工具提示上表數據等工具提示不工作後在表的jquery
和代碼
<tr>
<td class="text-center"><%=i %></td>
<td class="text"><span rel="tooltip" title="<%=client.getName() %>"><%=client.getName() %></span></td>
<td class="text"><span rel="tooltip" title="<%=client.getContactPerson() %>"><%=client.getContactPerson() %></span></td>
<td class="text"><span rel="tooltip" title="<%=client.getContactNumber() %>"><%=client.getContactNumber() %></span></td>
<td class="text"><span rel="tooltip" title="<%=client.getEmail() %>"><%=client.getEmail() %></span></td>
<td class="text"><span rel="tooltip" title="<%=client.getAddress() %>"><%=client.getAddress() %></span></td>
<td class="text"><span rel="tooltip" title="<%=client.getDepartment() %>"><%=client.getDepartment() %></span></td>
<td class="td-actions text-right">
</tr>
上分頁我正在通過jquery的填充數據,但添加行後,上述工具提示不起作用,這裏是我的javascript代碼
clients.forEach(function(client){
$("#paginationTable tbody").append("<tr>"+
"<td class=\"text-center\">"+(i+1)+"</td>"+
"<td class=\"text\"><span rel=\"tooltip\" title=\""+client.name+"\""+">"+client.name+"</span></td>"+
"<td class=\"text\"><span rel=\"tooltip\" title=\""+client.contactPerson+"\""+">"+client.contactPerson+"</span></td>"+
"<td class=\"text\"><span rel=\"tooltip\" title=\""+client.contactNumber+"\""+">"+client.contactNumber+"</span></td>"+
"<td class=\"text\"><span rel=\"tooltip\" title=\""+client.email+"\""+">"+client.email+"</span></td>"+
"<td class=\"text\"><span rel=\"tooltip\" title=\""+client.address+"\""+">"+client.address+"</span></td>"+
"<td class=\"text\"><span rel=\"tooltip\" title=\""+client.department+"\""+">"+client.department+"</span></td>"+
"<td class=\"td-actions text-right\">"+
"<button type=\"button\" rel=\"tooltip\" title=\"View Profile\" class=\"btn btn-info btn-simple btn-xs\">"+
"<i class=\"fa fa-user\"></i>"+
"</button>"+
"<button type=\"button\" rel=\"tooltip\" title=\"Edit Profile\" class=\"btn btn-success btn-simple btn-xs\">"+
"<i class=\"fa fa-edit\"></i>"+
"</button>"+
"<button type=\"button\" rel=\"tooltip\" title=\"Remove\" class=\"btn btn-danger btn-simple btn-xs\">"+
"<i class=\"fa fa-times\"></i>"+
"</button>"+
"</td>"+
"</tr>");
這是因爲它沒有事件偵聽器,因爲它是動態創建的。檢查這[**鏈接**](http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements)它可能會有所幫助! –
可能重複[Event binding on dynamic created elements?](http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements) –
可能是重複的。我需要實施。確切的解決方案 –