【发布时间】:2013-11-17 08:53:40
【问题描述】:
define([
'jquery',
'underscore',
'backbone',
'collections/jobs',
'text!templates/jobs/list.html'
], function($, _, Backbone, JobCollection, JobListTemplate){
var JobWidget = Backbone.View.extend({
el: '#bbJobList',
initialize: function () {
_.bindAll(this, 'detect_scroll');
$(window).scroll(this.detect_scroll);
this.isLoading = false;
this.jobCollection = new JobCollection();
},
render: function () {
this.loadResults();
},
loadResults: function () {
var that = this;
// we are starting a new load of results so set isLoading to true
this.isLoading = true;
this.jobCollection.fetch({
success: function (jobs) {
$(that.el).append(_.template(JobListTemplate, {jobs: jobs.models, _:_}));
// Now we have finished loading set isLoading back to false
that.isLoading = false;
}
});
},
close: function(){
this.remove();
this.unbind();
}
});
return JobWidget;
});
如何在关闭 RELOAD 渲染后移除它? 我打算重新渲染,更新数据在模型中,我将从控制器中取出(如果可能的话)
我试过了
this.render()
【问题讨论】:
标签: php jquery backbone.js underscore.js