我想列出我的數據來選擇的選項。我使用的把手骨幹jquery requireJS。把手選擇列表
這是我的模板
<select id="userSelect">
<option value="" selected="selected">Kullanıcı Seçiniz</option>
{{#each users}}
<option value='{{userID}}'>{{username}}</option>
{{/users}}
</select>
我查看
var users = new User();
var SelectUserList = Backbone.View.extend({
model: User,
el:'.page',
render:function(users)
{
var template = Handlebars.compile(SelectUserList);
var html = template({users:users.toJSON()});
$("#userSelect").html(html);
this.$el.html(SelectUserList);
return this;
}
});
return {
users:users,
SelectUserList:SelectUserList
};
而且我Router.js
user: function() {
var spinner = new Spinner();
$('body').after(spinner.spin().el);
var users = new Users();
var userSelect = new UserSelectList.SelectUserList();
users.fetch({
contentType: "application/json",
error: function() {
console.log("error");
},
cache: false,
success: function (m_users) {
userSelect.users=m_users;
userSelect.render(UserSelectList.users);
disposeView(new UserSelectList.SelectUserList().render());
}
});
DisposeView功能
function disposeView(view) {
var current = this.currentView;
if (current) current.close();
current = this.currentView = view;
current.delegateEvents();
return current;
}
而我有這個錯誤My Error
如何解決?我的錯在哪裏? 謝謝
我編輯了這個解決辦法,但現在同樣的異常錯誤「各不相匹配的用戶 - 3:7」 – real
哦,只要看到爲好{{#each我需要結束{{/每個}}而不是{{/ users}} – Quince