0

Im trying to integrate the popular stellar.js-module into my theme.

I go with the following. In my requirejs-config.js I have:

var config = {
    map: {
            '*': {
                'stellar': 'js/jquery.stellar.min'
            }
        },
        "shim": {
                "stellar": ["jquery"]
            }
};

and I utilize it by doing it this way:

require(['jquery', 'stellar'], function($) {

However, in my console I get this:

Uncaught ReferenceError: jQuery is not defined
    at jquery.stellar.min.js:2

Whats wrong here? The stellar plugin hasn't got modified from me.

  • please show your js file absolute path – Rakesh Jesadiya Feb 11 '17 at 4:51
5

Your requirejs-config.js file code like below :

var config = {
    "map": {
        "*": {
            "stellar": "Vendor_Modulename/js/jquery.stellar.min"
        }
    }
};

Make sure your js file location is view/frontend/web/js/jquery.stellar.min.js

and at last load your jquery in the template file(.phtml) like below code :

<script type="text/javascript">

    require(['jquery', 'stellar'],function($){
        (function() {

        })(jQuery);
    });
</script>   
  • It's a theme, so technically its just "js/...", which is it already. – Max Feb 11 '17 at 11:33
  • @Max if it is theme then pass "Vendor_Themename " – Manthan Dave Feb 11 '17 at 11:47
0

It looks like 'stellar' is dependant on jQuery, try changing to this:

var config = {
  paths:{
    'jquery.stellar':'js/jquery.stellar.min'
  },
  shim:{
    'jquery.stellar':{
        'deps':['jquery']
    }
  }
};
  • No change here, :/ – Max Feb 11 '17 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.