Start a new topic

Can backbone models and collections be created dynamically or do you need to create a .js file for e

In going through the backbone documentation, I found that this works:



Kinvey.init({

appKey : '***',

appSecret : '***'

})

.then(function (activeUser) {

//fetch a model

var books = new BooksCollection();



var promise = books.fetch({

success: function() {



console.log("Success fetching books!");



},



error: function() {



console.log("Error fetching books");

}



});

});



However, if instead, I instantiate the books object like this, it doesn't work:



var books = new Kinvey.Backbone.Collection([], {

url: 'books'

});



The URL is all that is in the books collection. Shouldn't it work the other way as well? The info I was following is here:

http://devcenter.kinvey.com/backbone/guides/datastore#Fetching

1 Comment

Both methods work. The following executes successfully for me:



Kinvey.init({

appKey : '',

appSecret : ''

}).then(function (activeUser) {

var books = new Kinvey.Backbone.Collection([], {

url: 'books'

});

var promise = books.fetch({

success: function () {

console.log("Success fetching books!");

},

error: function () {

console.log("Error fetching books");

}

});

});



You mentioned this doesn’t work for you - can you provide me with the error message, or description what actually happens?
Login or Signup to post a comment