jQuery live and sortable
我有以下静态html:
- Item https://stackoverflow.com/questions/4323639/jquery-live-and-sortable/10
- Item https://stackoverflow.com/questions/4323639/jquery-live-and-sortable/20
- Item https://stackoverflow.com/questions/4323639/jquery-live-and-sortable/30
- Item https://stackoverflow.com/questions/4323639/jquery-live-and-sortable/40
- Item https://stackoverflow.com/questions/4323639/jquery-live-and-sortable/50
我有以下jQuery:
$( document ).ready( function() { $("#mylist").sortable( {axis:"y"} ); });
这很好用,但是一旦我使用jQuery / AJAX生成上面的HTML就停止工作。 所以我假设我需要在jQuery中使用“live”函数来执行可排序部分。 有人可以帮我实现吗?
.live()
是基于事件的,所以你不能将它用于这样的插件。 您可以轻松完成的是在AJAX调用完成时调用该代码,例如:
$.ajax({ //options... success: function(data) { //create UL $("#mylist").sortable({axis:"y"}); } });
对于$.ajax()
简短forms也是如此,例如:
$("#mylist").load("pageThatGivesTheLIElementGoodness.htm", function() { $(this).sortable({axis:"y"}); })
- 有多个AJAX刷新和TinyMCE的问题
- 如何在带有数据表的模态中附加ajax结果
- 如何使用$ .ajax()将字符串数组从PHP传递给Javascript?
- Magento – AJAX将产品页面元素调用到类别页面。 选择Box Not Populated
- 使用jquery上传文件并作为PUT发送
- 如何处理所有AJAX调用的特定HTTP错误?
- 使用JavaScript获取表单数据并使用Ajax发送数据
- 在具有大量数据的mvc4中的ajax发布期间,系统抛出System.ArgumentExceptionexception
- 来自jQuery Ajax的Bool参数在PHP中作为文字字符串“false”/“true”接收