Closed mikehaas763 closed 9 years ago
It is happening because the third function (creating $.fn.outerHtml) has a dependancy on global var jQuery.
Temporary workaround Add a shim to your require config e.g.
require.config({
...
paths: {
...
"jQuery": "../Scripts/jquery-2.1.0",
"koBootstrap": "../Scripts/knockout-bootstrap",
shim: {
...
"koBootstrap": {
deps: ["jQuery"],
exports: "$.fn.outerHtml"
},
}
Permanent Fix All code should be contained in the "setupKoBootstrap" factory.
Then jQuery can be added to the AMD define dependencies (at the bottom of the script). Note there are also many other references to $ in the factory already (as expected with knockout binding handlers) that should be satisfied with a jQuery dependency.
But why is outerHtml() created as a jQuery function? And why are S4() and guid() added as globals? Shouldn't they all be private functions?
This can be closed now? I didn't think to put "closes #55" in my commits/PR. 😐
looks good to me!
When using this lib with requirejs, and loading jquery with requirejs (rather than just another script being loaded through the DOM) I get this error when loading from a completely cleared cache:
Uncaught ReferenceError: jQuery is not defined
However, if I do a soft refresh I do not get that error. I haven't looked into why the issue is happening yet but am just documenting it here.