Javascript jquery nestable不更新
我正在使用jquerynestable创建一个潜在学生可能感兴趣的学术课程列表。从mysql中提取16个程序,如下所示:Javascript jquery nestable不更新,javascript,php,jquery,mysql,Javascript,Php,Jquery,Mysql,我正在使用jquerynestable创建一个潜在学生可能感兴趣的学术课程列表。从mysql中提取16个程序,如下所示: <ol class="dd-list"> if(mysqli_num_rows($result)) { $order = array(); while($item = mysqli_fetch_assoc($result)) { echo '<li class="dd-item" data-id="'.$item['id']
<ol class="dd-list">
if(mysqli_num_rows($result)) {
$order = array();
while($item = mysqli_fetch_assoc($result)) {
echo '<li class="dd-item" data-id="'.$item['id'].'"><div class="dd-handle">',$item['program'],'</div></li>';
}
</ol>
} else {
<p>Sorry! There are no items in the system.</p>
}
Serialised Output (per list)
<textarea id="nestable-output"></textarea>
<textarea id="nestable2-output" name="nestable2-output"></textarea>
它只是有时会失败。然后,如果我在第二个容器中重新排序列表,它会更新,但在我再次重新排序之前不会更新任何新项目。非常感谢您的帮助。我找到了答案。问题出现在jquery.nestable.js文件第475行附近,是这样的:
$(this).data("nestable-id", new Date().getTime());
在速度更快的机器上,似乎没有足够的时间(毫秒)让脚本看到发生了更改。替换为:
$(this).data("nestable-id", Math.round(Math.random() * Math.pow(10, 16)));
任何一代随机数似乎都可以,所以这个答案不是唯一可以做到的方法
没有问题。
->,$item['program'],
如果我是你,我就不会那么肯定了。这些逗号肯定会引起一些问题。我喜欢它!似乎没有。列表已填充,没有抛出错误。但我将其更改为:echo'$(this).data("nestable-id", new Date().getTime());
$(this).data("nestable-id", Math.round(Math.random() * Math.pow(10, 16)));