| Issue 374: | Support UMD Loading | |
| 2 people starred this issue and may be notified of changes. | Back to list |
What new or enhanced feature are you proposing? Alter dynatree to support UMD/AMD Loading as per https://github.com/umdjs/umd/blob/master/jqueryPlugin.js or https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js What goal would this enhancement help you achieve? This will allow us to load dynatree in RequireJS without having to use a config shim.
Nov 13, 2012
would it be enough to add this add the end of the file?
if( typeof define === "function" && define.amd ) {
define( ["jquery"], function () {
return jQuery.ui.dynatree;
});
}
Nov 14, 2012
comment 1: I would expect dynatree would require both jquery and jquery-ui (but arguably you could require just jquery-ui, as it is dependent on jquery itself).
In terms of implementation, something along the lines of:
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'jquery-ui'], factory);
} else {
// Browser globals
factory(jQuery, jQuery.ui);
}
}(function ($, jQueryUI) {
$.ui.dynatree = function () { //dynatree stuff here};
}));
The above should be pretty much enough to support UMD/AMD loading, with one problem -the globals that dynatree creates (mainly for debugging I believe). It would be better to encapsulate them within the dynatree namespace, so they don't litter the global namespace. This way it wont conflict with anything else too. An alternative is to create them as a separate namespace as a dependency of dynatree, but that's probably overkill.
Jan 26, 2013
(No comment was entered for this change.)
Labels:
-Milestone-Release1.2.x Milestone-Release2.0
Aug 27, 2013
Any ideas on how to get this to work? Been trying the above mentioned methods without any joy
Oct 6, 2013
Closing 'Waiting' issues without timely answer
Status:
Done
|
Labels: Milestone-Release1.2.x