Last active
December 26, 2015 04:39
-
-
Save infacq/7094499 to your computer and use it in GitHub Desktop.
sampel guna backboneJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.Zoo = Backbone.Collection.extend({ | |
model:Makhluk, | |
url:"./api/makhluk", | |
initialize: function() { | |
this.deferred = this.fetch(); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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