Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backbone Marionette module starting, regardless of startWithParent setting

Tags:

marionette

I'm checking out Backbone Marionette and it seems promising for my current project. However, when adding modules they seem to auto start, regardless of the startWithParent setting. Here's a piece of the code I'm having issues with (part of it is actually copied from the Marionette docs):

var app = new Backbone.Marionette.Application();

var fooModule = app.module('fooModule', {
      startWithParent: false,

      define: function(){
          console.log('I should not auto start');
      }
    });

app.start();

I'm expecting "I should not auto start" not to appear in my console, but it does. To me it seems I should execute...

app.module('fooModule').start()

...before this message should appear.

I'm using Backbone.Marionette 1.0.2, Backbone 1.0 and Underscore 1.4.4.

Any clues as to why this is happening? Thanks for helping!

like image 260
Vanderstaaij Avatar asked Dec 04 '25 18:12

Vanderstaaij


1 Answers

Note that module initializers are called when the module is started, the define function is there to allow for module definition, but its execution doesn't mean that the module is started.

I've made a fiddle to explain what I mean: http://jsfiddle.net/Axg27/2/

like image 181
Alberto Zaccagni Avatar answered Dec 11 '25 07:12

Alberto Zaccagni