I try to work with RequireJS and AMD module definition and have write a module that do my things in object format i think. (i went from jquery and have not study a OOP javascript well)
myModule.js
define([
    jquery,
    datepicker,
], function ($, datepicker) {
    var myModule = {
        debug: true,
        lang: 'auto',
        initModule: function (element) {
            myModule.element = element;
        },
        // ... other methods
    }
    return myModule;
});
And it work well, but if i try to use it for more than one elements/time it override him self, and i can't use it more than one time in same page.
main.js
requirejs(['MyModule'],
    function (MyModule) {
        // all the elements on page
        $elements = $('.element');
        $elements.each(function () {
            MyModule.initModule($(this));
        });
});
When i have more than one <div class="element"> on page only the last one work, i think because my module is override him self.
I tried to add new MyModule() but have a error TypeError: MyModule is not a constructor
I think i need to add a constructor or something else, in any case have a instance of my module to use instead of the object (that i think are precompiled by requirejs and returned ready for work). Any helps are good, many thanks in advance!
