在iframe中使用jQuery可排序 [英] Using jQuery sortable inside an iframe
本文介绍了在iframe中使用jQuery可排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在iframe中加载一些html ,并使该html页面中的某些元素可排序:
I'm trying to load some html in an iframe and make certain elements in that html page sortable:
JS:
var _iframe = $('iframe');
var containment = _iframe.contents().find( "modules" );
if(containment.data('sortable')) containment.sortable('destroy');
containment.sortable({
stop: function (event, ui) {
console.log('STOP: I am never called');
},
start: function (event, ui) {
console.log('START: I am called with a delay!');
},
containment: containment,
placeholder: "sortable-placeholder",
items: "> module",
delay: 10,
forcePlaceholderSize: true,
helper: 'clone',
zIndex: 10000
});
这会导致一些意外的行为,例如延迟的开始事件和没有停止事件
This causes some unexpected behavior like delayed start event and no stop event at all
仅当内容在iframe内时,才会出现问题. 这是一个没有iframe的版本(及其工作方式)
The problem occurs only if the content is inside an iframe. Here's a version without iframe (and how it should work)
Try to sort the elements in this version (and keep you console open)
推荐答案
似乎唯一可行的解决方案是将代码放入iframe.也许iframe在父母打扫房间时不喜欢它...
Seems the only working solution is to put the code in the iframe. Maybe the iframe doesn't like it when it's parent clean up his room...
这篇关于在iframe中使用jQuery可排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文