I'm creating a Grails application which makes use of the RichUI plug in and the Atmosphere plug in. However, it looks like there's some sort of incompatibility with these plug ins. When I declare the resources tag in the head of the .gsp page, only one of the plug ins works correctly. If I declare like this:
<head>
<atmosphere:resources/>
<resource:rating />
...
only works the RichUI plug in (star rating). In the other way around it only works the atmosphere plug in:
<head>
<resource:rating />
<atmosphere:resources/>
...
Any idea why is this happening? Am I doing something wrong? Thanks very much.
UPDATE
This are the resources being imported in the gsp page:
<script type="text/javascript" src="/Ontourtest/plugins/atmosphere-0.4.1/js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="/Ontourtest/plugins/atmosphere-0.4.1/js/jquery.atmosphere.js"></script>
<script type='text/javascript' src='/Ontourtest/plugins/richui-0.8/js/prototype/prototype.js'></script>
<script type='text/javascrip开发者_Go百科t' src='/Ontourtest/plugins/richui-0.8/js/rating/behavior.js'></script><script type='text/javascript' src='/Ontourtest/plugins/richui-0.8/js/rating/rating.js'></script><link rel='stylesheet' href='/Ontourtest/plugins/richui-0.8/css//rating.css'></link>
Can you see any potential incompatibilities?
It could be a method name collision; both plugins may declare same-named functions in the default namespace. I've used YUI Namespacing to resolve this in my apps.
It could also be a conflict in plugin dependencies, such as each importing a different version of the same library. Try viewing the generated html of your gsp page to see what the plugin resource tags are importing.
edit:
I took a quick look through those Javascript libraries and the collision is likely the "$" token being used differently by JQuery (used by Atmosphere) and Prototype (used by RichUI).
According to the JQuery reference, calling "noConflict()" as below should resolve things. Keep in mind I haven't tried this and I don't know if the component .js files will now work without further modification:
<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$.noConflict();
// Code that uses other library's $ can follow here.
</script>
精彩评论