Closed GoogleCodeExporter closed 9 years ago
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?
Original comment by moo...@wwwendt.de
on 13 Nov 2012 at 5:33
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;
});
}
Original comment by moo...@wwwendt.de
on 13 Nov 2012 at 5:44
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.
Original comment by ll...@lloydpickering.com
on 14 Nov 2012 at 11:27
Original comment by moo...@wwwendt.de
on 26 Jan 2013 at 4:15
Any ideas on how to get this to work? Been trying the above mentioned methods
without any joy
Original comment by rovers...@gmail.com
on 27 Aug 2013 at 10:42
Closing 'Waiting' issues without timely answer
Original comment by moo...@wwwendt.de
on 6 Oct 2013 at 2:09
Original issue reported on code.google.com by
ll...@lloydpickering.com
on 8 Nov 2012 at 2:37