Nothing
Nothing

Reputation: 2642

Using jquery-ui datepicker with require.js

I searched some questions in here, but didn't get any solution. I'm trying to use datepicker in backbone.js require.js project.

main.js :

requirejs.config({
   enforceDefine: true,
   paths: {
      "jquery": "libs/jquery/jquery-min",
      "underscore": "libs/underscore/underscore",
      "backbone": "libs/backbone/backbone-min",
      "jquery-ui" : "libs/jquery/jquery-ui"
   },
   shim : {
      "underscore": {
         deps: [],
         exports: "_"
       },
       "backbone": {
         deps: ["jquery", "underscore"],
         exports: "Backbone"
       },
       "jquery-ui" : ['jquery']
   }
});

Here is my view :

define(["jquery","underscore","backbone","jquery-ui"], ,function($, _, Backbone,jqueryUI){

   //view code block

});

Just define it like this, and not yet call any function of jquery-ui then I got one error in my console Error: No define call for jquery-ui http://requirejs.org docs/errors.html#nodefine.

Any help would be appreciated.

Upvotes: 1

Views: 1377

Answers (2)

Muhaimin
Muhaimin

Reputation: 1643

as for jquery plugin, I prefer to convert to UMD module which is much cleaner way to avoid contamination of global variable

Upvotes: 0

Evgeniy
Evgeniy

Reputation: 2921

To make it work please set enforceDefine to false.

According to official docs

enforceDefine: If set to true, an error will be thrown if a script loads that does not call define() or have a shim exports string value that can be checked.

Upvotes: 1

Related Questions