views:

1586

answers:

3

Hi Guys,

I have a problem that I just cannot resolve and its driving me insane. I am using the jQuery library and I am using ".noconflict".

I am trying to use this on my blog with the following script -

http://www.internetmarketingmonitor.org/word-press-plugins/imm-glossary-wordpress-plugin

The problem is - I keep getting the following error -

>  [Exception... "Component returned failure code: 0x80070057
> (NS_ERROR_ILLEGAL_VALUE) [nsIDOMXPathEvaluator.evaluate]"  nsresult:
> "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame ::http://myblog.com/wp-content/plugins/IMM-Glossary/JavaScripts/prototype.js
> :: anonymous :: line 1081"  data: no]
> Source:http://myblog.com/wp-content/plugins/IMM-Glossary/JavaScripts/prototype.js

What's not making sense is that I AM USING .NOCONFLICT? - The error can be easily replicated by simply downloading this plugin and putting the *.js on the same page as jquery?

Would anyone be able to help ?

+2  A: 

I looked at the source, but don't see jQuery on the page right now.

Based on your comment to your original question, it sounds like you're not actively kicking off the noConflict function. You need to do something akin to this.

<script type="text/javascript" src="path/to/jquery.js"></script>
<script type="text/javascript">
    jQuery.noConflict();
</script>

You'll note the call to jQuery.noConflict is not wrapped in any sort of DOM ready check. You want to run it immediately after you include jQuery to be safe.

Brian Arnold
+1 I'm thinking he didn't call the function
Paolo Bergantino
+1  A: 

The $ is used by other javascript frameworks also. So when you have two of them there is a problem. jQuery plays nicely with other frameworks, you just need to call noConflict function:

<script type="text/javascript" src="..."/>
<script type="text/javascript">
  jq=jQuery.noConflict();
</script>

now you can call jquery functions using alias you have created above:

 <script type="text/javascript">
    jq(document).ready(function(){alert(jq);});
 </script>
TheVillageIdiot
Saying that "true is for stricter overriding default" is a bit misleading. The jQuery docs say the following:"This is a more-extreme version of the simple noConflict method, as this one will completely undo what jQuery has introduced. This is to be used in an extreme case where you'd like to embed jQuery into a high-conflict environment. NOTE: It's very likely that plugins won't work after this particular method has been called."Aliasing jQuery to jq works okay too, but I wouldn't call noConflict(true) without being 100% sure it was necessary.http://docs.jquery.com/Core/jQuery.noConflict
Brian Arnold
Thanks @brain I've modified it :)
TheVillageIdiot
A: 

Hi Guys,

Thanks for the response. The answer actually was found

http://docs.jquery.com/Using_jQuery_with_Other_Libraries#Including_jQuery_before_Other_Libraries

Basically, when this occurs - I need to put the jQuery script FIRST in my list of scripts - this was the primary issue. When jQuery wasnt the first script - it generated the error - regardless of the manner in which I call the .noconflict function.

Basically, the jquery script needs to be the first script called to avoid associated conflicts.