在这种情况下如何使用jquery-modal对话框?

时间:2013-06-19 05:56:04

标签: jquery

我已经在使用依赖于tablesorter.js文件的jquery.js。现在,我正在尝试使用模态对话框,该对话框最终依赖于jquery-1.9.1.js。由于2个jqueries不能在同一个模板上,我怎样才能让tablesorter.js和jquery对话框一起工作?如果我删除jquery.js并且只包含jquery-1.9.1.js,我得到:

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>

2 个答案:

答案 0 :(得分: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" />

如果再次发生错误,请尝试发布其他代码。

答案 1 :(得分: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>