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.

1
  • please show your js file absolute path Commented Feb 11, 2017 at 4:51

2 Answers 2

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>   
2
  • It's a theme, so technically its just "js/...", which is it already.
    – Max
    Commented Feb 11, 2017 at 11:33
  • @Max if it is theme then pass "Vendor_Themename " Commented Feb 11, 2017 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']
    }
  }
};
1
  • No change here, :/
    – Max
    Commented Feb 11, 2017 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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