2011-12-15 28 views
0

javascript noob here。所以我試圖在我的使用Prototype的Rails 3應用程序中使用這個s3上傳器jQuery示例here 。在閱讀jquery doc關於如何使用Prototype和jQuery並避免衝突之後,我很困惑在哪裏使用jQuery.noConflict();函數。在原型Rails應用程序內重用jQuery代碼

我計劃使用

jQuery.noConflict(); 
jQuery(document).ready(function($){ 
    // Do jQuery stuff using $ 
    $("div").hide(); 
}); 

封裝任意jQuery代碼,但它似乎並沒有發揮作用。

我的問題是

我應該把代碼包裝在jquery.js中嗎?來自plupload的js文件?助手中的JavaScript代碼?

回答

0

還有就是放在哪裏.noConflict()這裏一個很好的例子:http://api.jquery.com/jQuery.noConflict/

<script type="text/javascript" src="other_lib.js"></script> 
<script type="text/javascript" src="jquery.js"></script> 
<script type="text/javascript"> 
    $.noConflict(); 
    jQuery(document).ready(function($) { 
    // Code that uses jQuery's $ can follow here. 
    }); 
    // Code that uses other library's $ can follow here. 
</script> 
+0

這是否意味着我應該換任何jQuery代碼除了在jquery.js和代碼? – Arthur 2011-12-15 09:58:22

相關問題