我正在尝试修复一个问题,但到目前为止还没有运气。我正在开发一个骨干网(1.0)和一个单页应用程序requirejs(我是骨干新手)。我的HTML有3个div来显示部门列表,员工列表和员工详细信息。当我的初始页面加载时,它显示了部门列表,工作正常,到目前为止很好。当用户点击部门时,它会假设显示员工列表。这是我的问题,浏览器没有刷新。在firebug我能够看到“emplistdiv”正确填充。 。 (虽然整个页面的重新加载工作正常)
我的divs
<div class="deptdiv"></div>
<div class="emplistdiv"> </div>
<div class="empdiv"> </div>
路由器
router.on('route:open', function () {
var Emplist = new EmpListView();
Emplist.render();
});
查看
var EmpListView = Backbone.View.extend({
el: '.emplistdiv',
initialize: function () {
_.bindAll(this, 'render');
//this.collection.on('reset', this.render);
},
render: function() {
var self = this;
var emp = new EmpListCollection();
emp.fetch({
success: function(templist) {
console.log(templist.models.length);
var temp = _.template($(emptemplate).html(), { emplist: templist.models });
self.$el.html(temp);
}
});
}
});