4

I'm new to RequireJS and trying to figure out why this is happening. I have a custom file stickyNav.js in <vendor>/<theme>/web/js.

I've added a requirejs-config.js file in <vendor>/<theme>/web/.

var config = {
     map: {
         '*' : {
             'stickyNav': 'js/stickyNav'
         }
     }
 };

This is my js code (to call console.log as a test)

define([
    'jquery',
    'jquery/ui',
    'stickyNav'], function($, stickyNav){
        console.log('Working');
    }
 );

Obviously I have this wrong. I read the official doc's, but i'm still struggling.

1
  • We want to see your stickyNav.js, maybe the problem is inside Sep 25, 2020 at 15:09

1 Answer 1

1

correct code:

define([
    'jquery',
    'stickyNav',
    'jquery/ui'
], function ($, stickyNav) {
    console.log('Working');
});

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.