【发布时间】:2013-02-27 12:17:34
【问题描述】:
这应该是直截了当的,但是我在提醒我的可排序列表的顺序时遇到了麻烦。
这是我正在使用的 JQuery 代码:
$(document).ready(function() {
$("#projectItems").sortable({
update : function(event, ui) {
var order = $(this).sortable('toArray').toString();
alert(order);
}
});
});
这是我的列表的 HTML:
<ul id="projectItems">
<li id="item1" value="<?php echo $studentChoice1; ?>">(1) <?php echo $title[1]; ?><a href='#message1' onclick='deleteProject(".$studentChoice1.",".$userID.")'><img height=20px width=20px alt='Delete' src='img/delete.png' /></a></li>
<li id="item2" value="<?php echo $studentChoice2; ?>">(2) <?php echo $title[2]; ?><a href='#message1' onclick='deleteProject(".$studentChoice2.",".$userID.")'><img height=20px width=20px alt='Delete' src='img/delete.png' /></a></li>
<li id="item3" value="<?php echo $studentChoice3; ?>">(3) <?php echo $title[3]; ?><a href='#message1' onclick='deleteProject(".$studentChoice3.",".$userID.")'><img height=20px width=20px alt='Delete' src='img/delete.png' /></a></li>
<li id="item4" value="<?php echo $studentChoice4; ?>">(4) <?php echo $title[4]; ?><a href='#message1' onclick='deleteProject(".$studentChoice4.",".$userID.")'><img height=20px width=20px alt='Delete' src='img/delete.png' /></a></li>
<li id="item5" value="<?php echo $studentChoice5; ?>">(5) <?php echo $title[5]; ?><a href='#message1' onclick='deleteProject(".$studentChoice5.",".$userID.")'><img height=20px width=20px alt='Delete' src='img/delete.png' /></a></li>
</ul>
该列表是可排序的并且有效,但是当用户完成对项目的排序时,它根本不会显示警报消息。
这里的任何帮助将不胜感激,因为我已经被这个问题困扰了几天,似乎无法在线找到解决方案。
更新 问题似乎在于引用 jQuery
我正在使用的 jQuery 的当前版本是 1.7.1,来自 google 的 CDN,在我的脚本中引用如下:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
但是,当我将其更改为:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
根本没用!
当我尝试像下面这样的引用时,它说有一个 jquery 引用错误!
<link href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" href="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" href="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
我不知道如何解决这个问题,因为它似乎对其他人都很好! 在这里的任何帮助将不胜感激。
【问题讨论】:
标签: jquery jquery-ui jquery-ui-sortable