I have a model object defined like this
blog.js
define({title: '', url: '', summary: ''});
I'm using the blog
model to hold data from a service and I need to populate an array of blogs
. How do I instantiate a new blog
within a loop in another module?
I've tried passing in blog
as a require object, but it maintains it's reference inside the loop leaving an array of the same object over and over again.
othermodule.js
define(['blog'], function(blog) {
//... more code
$.each(data, function(index, b) {
var tmpBlog = blog;
//...
list.push(tmpBlog);
});
});
I've also tried using var blog = require('blog');
yielding the same result.
So how do I instantiate the blog object using requirejs?