У меня есть следующий шаблон HTML.Как спрятать и показать в позвоночнике
<script type="text/template" id="friend-request-list">
<div class="row-fluid">
<ul class="nav nav-stacked nav-pills">
<@ friendRequestCollection.each(function(user) { @>
<li id="user-list-<@= user.get('username') @>"><a href="#"><@= user.get('firstName') @></a></li>
<@ }); @>
</ul>
</div>
Этот шаблон показан в следующем pendingFriendRequest DIV,
<ul class="nav pull-left">
<li>
<div id="pendingFriendRequest" class="notired">${nbFriendRequest}</div><a href="#" class="notifriend"><i class="icon-eye-open icon-white"></i></a>
</li>
</ul>
Позвоночник код следующим
app.View.FriendRequestListView = Backbone.View.extend({
template: _.template($('#friend-request-list').html()),
tagName: 'div',
initialize: function(){
this.friendRequestCollection = new app.Collection.FriendRequestCollection();
this.friendRequestCollection.bind("reset", this.render, this);
this.friendRequestCollection.fetch();
var self = this;
},
render: function() {
$(this.el).html(this.template({
friendRequestCollection: this.friendRequestCollection}));
return $(this.el);
}
});
app.Collection.FriendRequestCollection = Backbone.Collection.extend({
url : function(){
return '/rest/friendRequests';
}
});
Но теперь то, что я хотел, что в списке должен быть невидимым, и только при щелчке ссылки список отображается как меню. При нажатии какой-либо другой или перемещение курсора в другое место меню должно скрываться.
IS это возможно. Я новичок в позвоночнике, поэтому не знаю, как это сделать.
Можете ли вы предоставить мне рабочий jsfiddle ... Большое спасибо –
Вы можете использовать ['@ $ (x)' (AKA 'this. $ (X)')] (http://backbonejs.org/#View-dollar) вместо '@ $ el.find (x)' или 'this. $ el.find (x)'. –
@muistooshort - Да, вы правы, но '@ $ el.find (x)' Я хотел доказать, что 'x' должен быть внутри контейнера' el' –