Issue 374: Support UMD Loading
Status:  Done
Owner: ----
Closed:  Oct 2013
Reported by ll...@lloydpickering.com, Nov 8, 2012
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
Project Member #1 moo...@wwwendt.de
I did  not use  RequireJS so far (only took a quick look at curl.js)

Can you recommend a best practice to do this without breaking standard includes?
And would you expect dynatree to 'require' jQuery?
Status: Waiting
Labels: Milestone-Release1.2.x
Nov 13, 2012
Project Member #2 moo...@wwwendt.de
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
#3 ll...@lloydpickering.com
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
Project Member #4 moo...@wwwendt.de
(No comment was entered for this change.)
Labels: -Milestone-Release1.2.x Milestone-Release2.0
Aug 27, 2013
#5 rovers...@gmail.com
Any ideas on how to get this to work? Been trying the above mentioned methods without any joy
Oct 6, 2013
Project Member #6 moo...@wwwendt.de
Closing 'Waiting' issues without timely answer
Status: Done