I am trying to learn backbone.js and I am having trouble understanding how to bind models and read them after retrieval. This is my code:
$(function() { var Bid = Backbone.Model.extend(); var BidsList = Backbone.Collection.extend({ model: Bid, url: '/buyers/auction/latestBids?auctionId=26&latestBidId=0', }); var BidsView = Backbone.View.extend({ el: $('#bids'), initialize: function() { log('hi'); _.bindAll(this, 'render'); this.collection = new BidsList(); this.collection.fetch(); this.render(); }, render: function() { log(this.collection); return this; }, }); var bidsView = new BidsView(); }); function log(m) { console.log(m); }
Here's what webservice json looks like
{ "AuctionState":3, "ClosedOn":null, "Bids":[ { "BidId":132, "AuctionId":26 }, { "BidId":131, "AuctionId":2 } ] }
How do I bind this answer to a model?
source share