jqueryrequirejsjquery-ui-multiselectrequirejs-define

AMD jQuery Multiselect Widget


I'm trying to use jQuery multi-select widget with AMD and handlebars. Here's the handlebars snippet:

{{#section 'js'}}
  <script type='text/javascript' nonce="{{nonce}}">
    requirejs([
      "domReady",
      "app/ui/js/utils/Chart.min",
      "app/ui/js/utils/jquery.multiselect",
      "app/ui/js/utils/jquery-ui.min",
      "app/ui/js/y",

    ],
    function(wrapper, domReady, x) {
      domReady(function() {
        $.when(wrapper.init()).then(
          function() {
            x.init();
          }
        );
      });
    });
  </script>
{{/section}}

Here are the contents of y.js:

define([
        'jquery',
        'app/ui/rest/x',
        'app/ui/js/utils/errorhandlingutils'
], function( $, restX, errorHandler ) {
    "use strict";
    function _init() {
        //Do something
    }
    return {
        init: function() {

            //Global Init function
            _init();
        }
    };
});

I want to use the multi-select widget in y.js. How should I do that?


Solution

  • I added "jquery" as a dependency in the handlebars snippet to resolve this.