jquery dwr冲突

jquery DWR 冲突
项目中引入jquery和DWR之后出现了在IE不能使用的问题,但是没有错误报出。换成firefox能够正常使用。并且在firebug下没有错误报出。

在调试过程中去除DWR代码,没有效果,仍然出错,但是去除引用头则不再出错。

经过几个小时排查均没有结果,最后找到了一篇blog,道出了其中原委。
Since DWR’s util.js uses $ as an alias to ‘dwr.util.byId’ function, it may not have a smooth integration with jQuery as $ is also used by the latter as a function alias. In order to resolve this conflict, one could follow snippet:

<script type='text/javascript' src='/mycontext/js/jquery-1.3.2.min.js'></script>
<script type="text/javascript">
    var jq = jQuery.noConflict();
</script>
<script type='text/javascript' src='/mycontext/dwr/engine.js'></script>
<script type='text/javascript' src='/mycontext/dwr/util.js'></script>
<script type="text/javascript">
   jq(document).ready(function()
   {  //other function calls
   });
</script>
‘jq’ variable defined in place of $ to invoke the rest of other jQuery functions.

你可能感兴趣的:(jquery)