secret

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
var Fishe = {};
 
Fishe.Deck = Backbone.Model.extend({
initialize: function () {
alert("Welcome to this world");
}
});
 
Fishe.DeckCollection = Backbone.Collection.extend({
model: Fishe.Deck,
url: 'http://fishes.localhost/deck.json',
sync: function (method, model, options) {
console.log('syncing');
var params = _.extend({
type: 'GET',
dataType: 'jsonp',
url: this.url,
success: function (data, textStatus, jqXHR) {
console.log(data)
},
error: function (jqXHR, textStatus, errorThrown) {
this.model.set($.parseJSON(jqXHR.responseText));
}
}, options);
 
return $.ajax(params).done(function () {
console.log('finished')
});
}
});
 
DeckView = Backbone.View.extend({});
 
 
Fishe.data = {};
Fishe.data.decks = new Fishe.DeckCollection();
 
Fishe.data.eventView = new DeckView({
el: $('#decks')
,collection: Fishe.data.decks
}) ;
 
Fishe.data.decks.fetch({
success: function () {
console.log(this.collection.toJSON());
},
error: function () {
console.log('Failed to fetch!');
}
});

Were u able to overcome this problem?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.