Using RequireJS for Recursive Map
I'm using requireJS for my web application, and I'm stumped on how to use
requireJS to build a recursive map of the same object. For example, my
object is called 'section', and I want to create a child below each using
the same object:
Section
> Section
> Section
> (etc...)
Here is the contents of section.js:
define(['jquery'], function($) {
children = [];
function init() {
require(['jquery', 'section'], function($, section) {
children.push(section.init(mediator, this));
});
return children;
}
return {
init: init
}
}
This has resulted in a self-referencing mess. I don't know how I can
create a new instance of section for the new, child section.
No comments:
Post a Comment