javascript - jeditable 意外触发嵌套项目上的 Draggable

标签 javascript jquery jquery-ui draggable jeditable

我正在使用 jquery-ui 的 draggable 进行拖放,并且 jeditable用于内联编辑。

当我拖放一个同样可编辑的元素时,jeditable 会立即启动并弹出“编辑模式”。

如何禁用此行为?

编辑 - 问题的发生是因为 netsting - 参见 this example .我还在混合中添加了 draggable 以使示例更加真实(实际真正的问题在我正在处理的 this site 中)

注意 - 尽管由于赏金规则这个问题有一个可接受的答案,但我仍然没有解决这个问题。

最佳答案

更新 2: 使用 children()

演示 2: http://jsbin.com/izaje3/2

回应你的评论

$(function() {
    $('.editable').editable();
    $('.draggable').draggable({
        drag: function(event, ui) {
            $(this).children('div').removeClass('editable')
        },
        stop: function(event, ui) {
           $(this).children('div').addClass('editable')
        }
    });
});​

演示: http://jsbin.com/ihojo/2

$(function() {
    $(".draggable").draggable({
        drag: function(event, ui) {
            $(this).unbind('editable')
        }
    });
    $(".editable").editable();
});

或者你可以这样做:

$(function() {
    $('.editable').editable();
    $('.draggable').draggable({
        drag: function(event, ui) {
            $(this).removeClass('editable')
        },
        stop: function(event, ui) {
            $(this).addClass('editable')
        }
    });
});

假设你有这样的东西:

<div class="draggable editable"></div>  

注意:为了方便,您也可以使用 handle 方法来利用!

http://jqueryui.com/demos/draggable/#handle

关于javascript - jeditable 意外触发嵌套项目上的 Draggable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2725264/

相关文章:

javascript - 如何在 Odoo 10 中应用 jquery/javascript 照片标签代码

javascript - 图库中的重复图像

javascript - ajax 调用后 $.ui 未定义

javascript - 如何利用按值存储来克隆对象?

javascript - 为什么我的 JQuery UI 对话框不注册 keydown 事件?

javascript - D3 : SVG downloadable, 但属性消失

单击链接时,jquery 在两个 UL 之间切换

javascript - 如何区分在html表单中单击了哪个按钮并基于该按钮通过ajax传递不同的值?

javascript - 页面打开一段时间后使用 jquery-ui 方法速度极慢

php - 在 ajax 请求中使用 JSON 响应更新 JQuery Progressbar