简体   繁体   English

在可排序的jQuery UI中对项目进行排序时,可编辑区域消失

[英]Editable area disappears when sorting item in a jquery UI sortable

The title may sound weird. 标题听起来很奇怪。 Well, it is. 好吧,是的。

Here's an approximation of my code (it lacks some useless ajax calls for this example, and simplifies some other stuff): http://jsfiddle.net/pKNAz/3/ 这是我的代码的近似值(此示例缺少一些无用的ajax调用,并且简化了其他内容): http : //jsfiddle.net/pKNAz/3/

Suppose you have a list of draggable items (in this case, there's only a draggable called "Add a Wysiwyg") which you can move into a drop zone (a grey rectangle in my example), and it appends a textarea, which then, after dropping, I convert into a wysiwyg using the jwysiwyg library (i couldn't add all the images and css this plugin uses, but the textarea basic behaviors (ctrl+b, ctrl+i, ctrl+u) work, so we can assume it's working). 假设您有一个可拖动项列表(在本例中,只有一个可拖动项,称为“添加所见即所得”),您可以将其移动到放置区域(在我的示例中为灰色矩形),并附加一个文本区域,然后,删除后,我使用jwysiwyg库将其转换为wysiwyg(我无法添加此插件使用的所有图像和CSS,但是textarea的基本行为(ctrl + b,ctrl + i,ctrl + u)起作用,因此我们可以假设它正在工作)。

It works particularly well at drop time. 它在下降时间特别有效。 However it turns to break the jwysiwyg when sorting. 但是,排序时会破坏jwysiwyg。 You can try it by yourself dragging the dark grey handle after having two jwysiwyg's. 您可以在拥有两个jwysiwyg之后,通过拖动深灰色手柄自己尝试一下。 You'll see the jwysiwyg you sorted has lost its jwysiwyg. 您会看到排序的jwysiwyg失去了它的jwysiwyg。 You can still get the correct value you previously wrote inside the textarea by searching $('textarea.overflow').val() , but you cannot use jwysiwyg anymore. 您仍然可以通过搜索$('textarea.overflow').val()来获得先前在textarea中写入的正确值,但是您不能再使用jwysiwyg。

Has anybody an idea on how to solve this problem? 有没有人知道如何解决这个问题? Thanks in advance 提前致谢

Ok, I got a solution (sorry Jan for removing your tick). 好的,我有解决方案(对不起,扬,消除您的勾选)。 I wondered that, if the problem was due to the combination between the iframe zone and the sort events, the why not just refresh the wysiwygs? 我想知道,如果问题是由于iframe区域和排序事件之间的结合引起的,为什么不只刷新所见即所得呢?

I create a function to wrap the destruction+construction of jwysiwyg, like this: 我创建了一个包装jwysiwyg的破坏+构造的函数,如下所示:

function refreshTextareas()
{
    $('textarea.autogrow').wysiwyg('destroy');
    $("textarea.autogrow").wysiwyg({
        autoGrow: true,
        rmUnusedControls: true,
        controls: {
            bold: { visible : true },
            italic: { visible : true },
            insertOrderedList: { visible : true },
            insertUnorderedList: { visible : true },
            removeFormat: { visible : true },
            h1: { visible: true },
            link : { visible: true }
        }
    });
}

and then I call it here: 然后我在这里称呼它:

$( "#sortable" ).sortable({
    stop : function(event, ui){
        refreshTextareas();
    }
});

So, in case you sort the stuff, you reconstruct it and it works again, just like that. 因此,万一您对材料进行了分类,则可以对其进行重构,然后它又可以正常工作,就像这样。

On dropping the item the iframe containing the wysiwyg control gets emptied. 放下该项目后,包含所见即所得控件的iframe就会清空。 Since a least-code scenario reproduces the error it looks like a bug in jquery/jwysiwyg. 由于最少代码方案会重现该错误,因此它看起来像jquery / jwysiwyg中的错误。

http://jsfiddle.net/6TcM7/2/ http://jsfiddle.net/6TcM7/2/

Report a bug and/or switch wysiwyg engine. 报告错误和/或切换所见即所得引擎。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM