2012-09-27 65 views
0

我有一個jQuery的衝突錯誤。請提供解決方案。jrecorder jQuery的衝突

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script><script> 
var r=jQuery.noConflict(true); 
://function related to 'r' here.... 
<body> 
<script src='recorder/jquery.js'></script> 
<script src="recorder/recorder.js"></script> 
//these files are present...cross checked twice... 
<script> 
var j=$.noConflict(true); 
j(document).ready(function(){ 
j.jRecorder({ 
    : //all settings here 
}); 
}); 
</script> 
</body> 

上部工作正常,但下部完全不工作。我使用jrecorder:http://www.sajithmr.me/jrecorder-jquery

回答

0

您需要使用此結構

$.noConflict(); 
     jQuery(document).ready(function($) { 
     // Code that uses jQuery's $ can follow here. 
     }); 

使用

$(function() { 
    // Code that uses jQuery's $ can follow here. 
}); 

insted的的

J.j(document).... 

說明: $.noConfilct() - corrcet valut設定的別名JQuery的。它不會返回$。

從文檔

許多JavaScript庫使用$作爲函數或變量名,就像jQuery不會。 在jQuery的例子中,$只是jQuery的別名,所以所有的功能都可以在沒有 的情況下使用$。如果我們需要使用另一個JavaScript庫jQuery的旁邊,我們可以返回$回控制其他庫到$ .noConflict()的調用:

更多細節到這裏看看jQuery.noConflict

+0

解釋會有幫助...爲什麼我的代碼是錯誤的....? –

+0

我試過的代碼,但沒有工作.....對不起 –

+0

你應該使用$ .jRecorder不是J –