Conflict with you JQuery Widgets and duplicated loading of jQuery Libraries [SOLUTION]

7
One on my things that annoys me, is the use of many libraries in widget. The different versions that conflict by overwriting others. Or when the same version is used in a correct way, the it is loaded once for each widget. So what can you do about it..... How to solve the conflicts in the library : dojo.provide("ClosurLoading.lib.jquery-183-min"); // The jQuery library ClosurLoading.lib.$ = $.noConflict(); In your widget: dojo.require("ClosurLoading.lib.jquery-183-min"); (function($) { // Your widget code can use '$' to access this version of jquery })(ClosurLoading.lib.$); How to share your jQuery libraries: How to share your jquery library: “One Widget to rule them all, One Widget to find them, One Widget to bring them all and in the light bind them” I have create a widget that include all latest releases of jQuery. Version 1.7 and up. (The AMD loading is included from 1.7 and upwards). Usable for Mendix 5.0 and up. Include this widget in one of your Application pages, so it the jQuery Libs are loaded in the runtime. In the index.html include the packages you need in the dojoConfig: dojoConfig = { isDebug: false, rtlRedirect: "index-rtl.html", baseUrl: "mxclientsystem/dojo/", packages: [ { name: 'jquery17', location: '../../widgets/jQueryLib', main: 'jquery-172-min' }, { name: 'jquery18', location: '../../widgets/jQueryLib', main: 'jquery-183-min' }, { name: 'jquery19', location: '../../widgets/jQueryLib', main: 'jquery-191-min' }, { name: 'jquery110', location: '../../widgets/jQueryLib', main: 'jquery-110-min' }, { name: 'jquery111', location: '../../widgets/jQueryLib', main: 'jquery-1111-min' }, { name: 'jquery20', location: '../../widgets/jQueryLib', main: 'jquery-203-min' }, { name: 'jquery21', location: '../../widgets/jQueryLib', main: 'jquery-211-min' } ] }; In the widget require the necessary jQuery package like: require(["jquery17", "jquery18", "jquery19", "jquery110", "jquery111", "jquery20", "jquery21"], function(jQuery17, jQuery18, jQuery19, jQuery110, jQuery111, jQuery20, jQuery21) { // Your Lib or Widget Code, access jQuery via the variable 'jQuery19' (or other version) }); To make the jQuery libraries load you need to set the AMD loading: dojo.provide("jQueryLib.jquery-110-min"); define.amd.jQuery = true; // user Orginal jquery file and replace 'define("jquery"' by the package mapping name sample: 'define("jquery110"' // Include here your jquery library, don’t forget to change redefinition name Go Ahead and download and extend the library package with whatever you need! Some background blog about jQuery packages in Dojo @ Mendix: It would it be nice include most common used library in the distribution of the modeler and server.
asked
0 answers