javascript - Using RequireJS for Recursive Map -


i'm using requirejs web application, , i'm stumped on how use requirejs build recursive map of same object. example, object called 'section', , want create child below each using same object:

section   > section     > section         > (etc...) 

here 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 self-referencing mess. don't know how can create new instance of section new, child section.

this can done without changing requirejs parts. idea create reference self, similar window.self?

function section() {     this.children = []; } var section = new section(); section.children.push(section); 

if each section has child new section, unless it's generated on demand, code loop infinitely constructing section after section.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -