2013-06-19 42 views
0

我已經在使用tablesorter.js這是依賴於jquery.js文件。現在,我試圖使用原來依賴於jquery-1.9.1.js的模式對話框。由於2個jquery不能在同一個模板上,我怎樣才能同時使用tablesorter.js和jquery對話框?如果我刪除的jquery.js,只包括jQuery的1.9.1.js,我得到:如何在這種情況下使用jquery-modal對話框?

Uncaught TypeError: Object [object Object] has no method 'tablesorter' 

錯誤。

如果我刪除了jQuery的1.9.1.js和僅包含的jquery.js然後我得到以下錯誤:

Uncaught TypeError: Object #<Object> has no method 'dialog' 

我使用JavaScript和CSS這樣的:

<script type="text/javascript" src="{{ STATIC_URL }}/js/jquery-latest.js"></script> 
<script type="text/javascript" src="{{ STATIC_URL }}/js/jquery.tablesorter.js"></script> 

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
+0

._0 ..你爲什麼要包括兩次相同的庫? – Zim84

+0

你沒有正確的讀過這個問題嗎?我在我的問題中已經說過了。 – pynovice

+0

如果您已經包含最新版本的jQuery,爲什麼要包含jquery-1.9.1,那麼表單和對話框都將與單庫運行 – Arunu

回答

1

您的代碼

<script type="text/javascript" src="{{ STATIC_URL }}/js/jquery-latest.js"></script> 
<script type="text/javascript" src="{{ STATIC_URL }}/js/jquery.tablesorter.js"></script> 

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 

包含兩個jquery庫。

<script type="text/javascript" src="{{ STATIC_URL }}/js/jquery-latest.js"></script> 

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 

選擇之一。試試這個

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
<script type="text/javascript" src="{{ STATIC_URL }}/js/jquery.tablesorter.js"></script> 

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 

如果再次發生錯誤,請嘗試發佈其他代碼。

+0

是的,它的工作。謝了哥們! – pynovice

1

您需要刪除下面的行,

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 

,它應該看起來像,

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
<script type="text/javascript" src="{{ STATIC_URL }}/js/jquery-latest.js"></script> 
<script type="text/javascript" src="{{ STATIC_URL }}/js/jquery.tablesorter.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>