-
1. Re: Problem with jQuery and CEP 5 - "$" getting overrided
bigtimebuddy Jun 19, 2014 8:41 PM (in response to Venky Murthy)I'm seeing the same issue here, I'm unable to load jQuery into my project. Any luck?
Trying to reference window.jQuery doesn't work either. $ is already set and doesn't seem to be able to overwrite-able.
-
2. Re: Re: Problem with jQuery and CEP 5 - "$" getting overrided
bigtimebuddy Jun 19, 2014 9:14 PM (in response to bigtimebuddy)I found a workaround! The problem seems to be that there's an immutable window property $ being set by Adobe. When jQuery tries to set $, it has big issues. I was able to modify jQuery to get it to work by removing the use of $ all together.
In jQuery 2.1.1, check out the uncompressed file. Remove lines 9159-9183 (this does the $ assignment) and simply replace with:
window.jQuery = jQuery;
In order to use jQuery, you can no longer use the $ unless you use it as a locally-scoped variable. I would suggest something like this:
(function($){
// $ is safe to use here
$('a').click(); // no problems
}(jQuery));
-
3. Re: Problem with jQuery and CEP 5 - "$" getting overrided
Hallgrimur Bjornsson Jun 20, 2014 7:42 AM (in response to bigtimebuddy)Hi,
This is because CEP 5's Node integration is overriding some JQuery variables.
This is the way to fix it:
Add the script below inside script tag to define window.module as undefined.
<script type="text/javascript">window.module = undefined</script> -
4. Re: Problem with jQuery and CEP 5 - "$" getting overrided
Hallgrimur Bjornsson Jun 23, 2014 4:48 AM (in response to Hallgrimur Bjornsson)Here's more detail: Extending Adobe CC 2014 apps — Medium
-
5. Re: Re: Problem with jQuery and CEP 5 - "$" getting overrided
mogeneration Jun 23, 2014 10:17 PM (in response to Hallgrimur Bjornsson)That fix does not work for me.
The only thing that works (without hacking jQuery itself, which I do not want to do) is using a wrapper HTML page and loading the whole extension HTML into an iFrame with the nodejs-disabled="true" attribute set.
Node.js should be an opt-in feature if it clobbers things in the global namespace that cause vital libraries like jQuery to fail. Either that, or Adobe needs to fix things so that jQuery and node can coexist successfully without colossal hacks.
The node.js functionality is great but not if it breaks existing stuff.
-
6. Re: Re: Re: Problem with jQuery and CEP 5 - "$" getting overrided
Hallgrimur Bjornsson Jun 24, 2014 1:30 AM (in response to mogeneration)Hi,
The next release will support a parameter in the Manifest that disables Node.js entirely.
Like this:
<CEFCommandLine> <Parameter>--nodejs-disabled</Parameter> </CEFCommandLine>
-
7. Re: Problem with jQuery and CEP 5 - "$" getting overrided
janmatousek Jun 30, 2014 7:29 AM (in response to Venky Murthy)One workaround is also to use require function to include jquery. Instead of
<script src="../lib/3rd/jquery-1.10.2.js"></script>
use
<script>
window.jQuery = require('../lib/3rd/jquery-1.10.2.js');
</script>
It does not create window.$, but at least it creates the window.jQuery.
-
8. Re: Problem with jQuery and CEP 5 - "$" getting overrided
Björn Lindström Jul 11, 2014 6:17 AM (in response to Venky Murthy)The fairly clean solution I arrived at was to build my own jQuery according to the instructions at jquery/jquery · GitHub, with 'exports/global' disabled (i.e. with 'grunt custom:-exports/global'), and load it from the html file like this:
<script src="path/to/my/jquery.min.js"></script><script type="text/javascript>var jquery = module.exports;</script>
and then have my main script look like this:
(function ($) {
// my codehere
}(jquery));
-
9. Re: Problem with jQuery and CEP 5 - "$" getting overrided
Milchek Aug 21, 2014 3:46 AM (in response to Venky Murthy)Strangely I had the same issue with conflict, for some odd reason using jquery-2.0.3 was fine for me but not jquery-2.1.1. Any ideas?
-
10. Re: Problem with jQuery and CEP 5 - "$" getting overrided
Rambutan Oct 28, 2014 11:14 AM (in response to Hallgrimur Bjornsson)Is there an official fix to this? It kinda sucks for new people just starting out when there's all these jQuery examples that don't work
I just tried adding the CEFCommandline tag to my manifest, didn't do anything. Is there a tag it needs to go inside of?


