Polling for lesson updates (updates the menu and page navigation)
This commit is contained in:
@ -1,29 +1,33 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/MenuModel'],
|
||||
function($,_,Backbone,MenuModel) {
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/MenuModel'],
|
||||
function ($, _, Backbone, MenuModel) {
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: MenuModel,
|
||||
url:'service/lessonmenu.mvc',
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.fetch();
|
||||
},
|
||||
return Backbone.Collection.extend({
|
||||
model: MenuModel,
|
||||
url: 'service/lessonmenu.mvc',
|
||||
|
||||
onDataLoaded: function() {
|
||||
this.trigger('menuData:loaded');
|
||||
},
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.fetch();
|
||||
setInterval(function () {
|
||||
this.fetch()
|
||||
}.bind(this), 5000);
|
||||
},
|
||||
|
||||
fetch: function() {
|
||||
var self=this;
|
||||
Backbone.Collection.prototype.fetch.apply(this,arguments).then(
|
||||
function(data) {
|
||||
this.models = data;
|
||||
self.onDataLoaded();
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
onDataLoaded: function () {
|
||||
this.trigger('menuData:loaded');
|
||||
},
|
||||
|
||||
fetch: function () {
|
||||
var self = this;
|
||||
Backbone.Collection.prototype.fetch.apply(this, arguments).then(
|
||||
function (data) {
|
||||
this.models = data;
|
||||
self.onDataLoaded();
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user