As we using an older jQuery version (1.4) along with a newer one (1.11), we have 2 different namespaces for them. 1.4 uses the standard $ and 1.11 uses jQuery1111.
Now I'm trying to implement the froala editor, which need to use the 1.11 version. I've changed the froala code to this to make that happen:
(function (a) {
"function" == typeof define && define.amd ? define(["jquery"], a) : "object" == typeof module && module.exports ? module.exports = function (b, c) {
return void 0 === c && (c = "undefined" != typeof window ? require("jquery") : require("jquery")(b)), a(c), c
} : a(jQuery)
}(function (a) {
...
}(window.jQuery1111)));
But this gives me the error a is not a function
(but the script seems to be able to run). The error is caught on the 4th line in the script above.
If I change a(jQuery)
on the 4th line to jQuery1111
it runs with no errors, but Im not sure if thats correct or if it will result in a bug later on.
Is this the correct way of implementing a 3rd party component into a non default jQuery namespace?
Update: Script Order
Inside <head />
<script src="/js/jquery.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var jQuery1111 = jQuery.noConflict(true);
window.jQuery1111 = window.jQuery1111 || jQuery1111;
</script>
Inside <body />
<script type="text/javascript" src="/scripts/froala_editor.min.js"></script>
You could change the order of script include to fix the issue without modifying the 3rd party libraries
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.1.0/js/froala_editor.min.js"></script>
<script type="text/javascript">
var jQuery1111 = jQuery.noConflict(true);
window.jQuery1111 = window.jQuery1111 || jQuery1111;
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.