Skip to content

Instantly share code, notes, and snippets.

@infacq
Last active December 26, 2015 04:39
Show Gist options
  • Save infacq/7094499 to your computer and use it in GitHub Desktop.
Save infacq/7094499 to your computer and use it in GitHub Desktop.
sampel guna backboneJS
window.Zoo = Backbone.Collection.extend({
model:Makhluk,
url:"./api/makhluk",
initialize: function() {
this.deferred = this.fetch();
}
});
var AplRouter = Backbone.Router.extend({
routes:{
"" : "senarai"
},
initialize: function() {
this.senarai_binatang = new Zoo();
this.senarai_binatang.fetch();
},
senarai:function () {
var _this = this;
this.senarai_binatang.deferred.done(function() {
_this.s_binatang_View = new ZooView({model:_this.senarai_binatang});
$('#sidebar').html(_this.s_binatang_View.render().el);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment