我在我的項目上使用backbone,jquery和handlebars。JQuery更改表上的一行
我試圖改變行類只是點擊。
我的意思是如果我點擊編輯按鈕(表的右邊),它會改變類。
看看錶格截圖瞭解。
AdminTableView.js
var addAdminPanelView = Backbone.View.extend({
el:$(".page"),
events:{
'click #editButton':'editEvent',
'click #deleteButton':'deleteEvent'
},
editEvent:function(){
console.log("edit");
this.$el.children().find("th").addClass("info");
},
我的模板
<tbody id="myTable">
<tr class="active">
{{#travels}}
<th>{{user.department.departmentName}}</th>
<th>{{user.managerID}}</th>
<th>{{user.firstName}} {{user.lastName}}</th>
<th>Seyahat Başlangıcı</th>
<th>Seyahat Sonu</th>
<th>{{location}}</th>
<th>{{travelPurpose}}</th>
<th>{{travelCost}}</th>
<th>{{projectCode}}</th>
<th> <a href="/#travel">
<span id="deleteButton" class="glyphicon glyphicon-minus-sign"></span>
</a>
<a href="#">
<span id="editButton" class="glyphicon glyphicon-edit"></span>
</a>
</th>
{{/travels}}
</tr>
</tbody>
如果我點擊任何編輯按鈕,所有的行添加類 「信息」
由於這是工作! – real
我們可以聊天,如果你想知道它爲什麼有效。 ;) –