HI Vasilio!
It's me again!
Having a hard time trying to figure out how to change a .$newCollection of models's url at runtime.
We have scenarios where we have a model, and you can have several different Rest URLs to get a collection of these models.. depending on scenario.
- I can't seem to get the baseUrl(#)s from my model definition at runtime with .$newCollection, I can only get a 'baseUrl'.
- I CAN seem to get different 'baseUr(#) if I use a .$new, but I need a .$newCollection
- The fetch ({url:urlValue}) doesn't seem to work for .$newCollection either
So:
// Lets define some models first, with different Rest urls
// =============================
modelize.defineModel('post', {
baseUrl: '/blog/postsdefault',
baseUrl1: '/blog/posts111',
baseUrl2: '/blog/posts222',
baseUrl3: '/blog/posts333'',
...
})
});
// Fetch collection
// ================
// Create empty collection
var posts = Post.$newCollection();
// Then fetch with different paths
// these are just different scenarios of course
var baseUrl = posts.baseUrl // works
var baseUrl1 = posts.baseUrl1 // undefined
var baseUrl2 = posts.baseUrl2 // undefined
var baseUrl3 = posts.baseUrl3 // undefined
posts.fetch({ url: baseUrl1 });
posts.fetch({ url: baseUrl2 });
posts.fetch({ url: baseUrl3 });
HI Vasilio!
It's me again!
Having a hard time trying to figure out how to change a .$newCollection of models's url at runtime.
We have scenarios where we have a model, and you can have several different Rest URLs to get a collection of these models.. depending on scenario.
So:
// Lets define some models first, with different Rest urls // ============================= modelize.defineModel('post', { baseUrl: '/blog/postsdefault', baseUrl1: '/blog/posts111', baseUrl2: '/blog/posts222', baseUrl3: '/blog/posts333'', ... }) }); // Fetch collection // ================ // Create empty collection var posts = Post.$newCollection(); // Then fetch with different paths // these are just different scenarios of course var baseUrl = posts.baseUrl // works var baseUrl1 = posts.baseUrl1 // undefined var baseUrl2 = posts.baseUrl2 // undefined var baseUrl3 = posts.baseUrl3 // undefined posts.fetch({ url: baseUrl1 }); posts.fetch({ url: baseUrl2 }); posts.fetch({ url: baseUrl3 });