Welcome
Login
Sign up
Home
Solutions
Forums
How can we help you today?
Enter your search term here...
Search
Login
or
Signup
to submit a new ticket
Check ticket status
Start a new topic
Discussions
Kinvey Forums
JavaScript
Can backbone models and collections be created dynamically or do you need to create a .js file for e
E
Erich Specht
started a topic
about 7 years ago
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
M
Mark
said
about 7 years ago
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
More topics in
JavaScript
How do I use Kinvey in my web app?
Is it safe to include keys/secrets in my client-side JavaScript app?
Why is the activeUser null even though I am logged in?
Login does not work even though credentials are valid.
Social login doesn’t work.
Appending objects to an Array (HTML5 - JS)
New to node.js - need bootstrap to downloadfiles from Kinvey
Problem with Aggregation/Grouping
Internal Server Error using Twitter Sign Up
Data Store
See all 315 topics
Erich Specht
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