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
Backbone usage
N
Nico Barelmann
started a topic
over 6 years ago
Hey,
a small (and hopefully easy) question regarding the Backbone Library of Kinvey.
1. Fetching a specific amount from the data-store
2. On another place in the application i want to access this collection but not fetch it again.
What i thought:
I can use the "map" functionality from Backbone to loop through each element, this doesn't seems to work.
What is the best practise for this? Fetching again with "offline" set to true?
Best,
Nico
3 Comments
Oldest First
Popular
Newest First
Sorted by
Oldest First
M
Mark
said
over 6 years ago
Did you try looping over the models property?
collection.fetch(...);
// Later on, loop over the models.
for(var model in collection.models) {
// Do something with the model.
}
N
Nico Barelmann
said
over 6 years ago
Hey,
sure that works :)
But i mean... It's the "backbone" library - shouldn't the backbone methods work there?
I think that searching/looking for an expliciti model by a property is a often use case.
Best, Nico
M
Mark
said
over 6 years ago
The `collection.map` method should work as well. What exactly didn’t work?
If I try to run the following script, it logs a line for every model in the collection (without refetching it).
```
var c = new Kinvey.Backbone.Collection([],{ url: 'collection'});
c.fetch().then(function() {
c.map(function(model, index, collection) {
console.log("Model", model);
});
});
```
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
Nico Barelmann
a small (and hopefully easy) question regarding the Backbone Library of Kinvey.
1. Fetching a specific amount from the data-store
2. On another place in the application i want to access this collection but not fetch it again.
What i thought:
I can use the "map" functionality from Backbone to loop through each element, this doesn't seems to work.
What is the best practise for this? Fetching again with "offline" set to true?
Best,
Nico