0

I'm using requirejs to load jquery.selectBoxIt. It uses the jQueryUI Widget factory, which is why I only loaded the widget factory from the jQueryUI official site into my project.

When the project is loaded with config.js, selectBoxIt runs without problems. But when I build the project with r.js, I get the error $.widget is not defined.

Please help me please fix it.

PS. I already read some Google results on it, but nothing helps.

config.js

require.config({
    paths: {
        'jquery': 'assets/libs/jquery/2.2.0/jscript/jquery.min',
        'jquery.migrate': 'assets/libs/jquery/plugins/migrate/1.2.1/jscript/migrate.min',
        'jquery.ui': 'assets/libs/jquery.ui/1.12.0/jscript/jquery-ui',
        'jquery.selectboxit': 'assets/libs/jquery/plugins/selectboxit/3.8.1/jscript/selectBoxIt',
    },
    shim: {
        'jquery.migrate': {

            deps: ['jquery'],
            exports: 'jQuery',
        },
        'jquery.selectboxit': {

            deps: ['jquery.migrate', 'jquery.ui'],
        },
    },
});

module.js

define([
    'jquery.selectboxit',
], function (SelectBoxIt) {
    ...
});

Error appear in selectBoxIt code in line

$.widget("selectBox.selectBoxIt", {
Mike
  • 3,830
  • 2
  • 16
  • 23
Evgeniy
  • 3,219
  • 5
  • 25
  • 40
  • 1
    Please add to your question the build configuration you give to the optimizer and how you load RequireJS on the page, load its run-time configuration (`require.config`) and kick off your application. (For the 2nd point, you can just add the `script` elements you use in your HTML in the same order as they appear in the HTML.) – Louis Aug 18 '16 at 10:34
  • 1
    try to add "jquery" as deps in "jquery.selectboxit ". – harilalkm Aug 18 '16 at 11:56
  • Thank for answears! I wrap selectBoxIt code in define with jquery.migrate and jquery.ui as dependence and it works! – Evgeniy Aug 18 '16 at 12:07

0 Answers0