ierax (4) [Avatar] Offline
#1
I have a link in one module (e.g. spa.menu.js) and want to use smooth scrolling to visit an element in another module (e.g. spa.content.js). How can I integrate a plugin like https://github.com/kswedberg/jquery-smooth-scroll with my spa? That's what I have done so far (including only the interesting parts):

spa.html
<script src="js/jquery-1.12.2.js"></script>
<script src="js/jquery.smooth-scroll.js"></script>


spa.menu.js
spa.menu = (function () {
     var
         configMap = {
           main_html : String()
            + '<a href="#foo">Foo</a>'
     };

    initModule = function ( $container ) {
        $container.html( configMap.main_html );
        stateMap.$container = $container;
        $('a').smoothScroll();
       return true;
    };
}());


spa.content.js
spa.content = (function () {
  var
    configMap = {
      main_html : String()
       + '<p id="foo">This is foo</p>'
    };

    initModule = function ( $container ) {
        $container.html( configMap.main_html );
        stateMap.$container = $container;
        return true;
    };
}());