Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从没有名称和Id值的元素中分离CK编辑器_Javascript_Jquery_Html_Ckeditor_Ckeditor4.x - Fatal编程技术网

Javascript 从没有名称和Id值的元素中分离CK编辑器

Javascript 从没有名称和Id值的元素中分离CK编辑器,javascript,jquery,html,ckeditor,ckeditor4.x,Javascript,Jquery,Html,Ckeditor,Ckeditor4.x,我正在一个CMS上工作,其中的元素是动态创建的,一些是预加载的,我需要将CK编辑器从那些预加载的元素中分离出来,并将CK编辑器再次附加到目标区域中的所有可编辑元素,包括预加载的元素 I'm in this loop, that gives me the target div being appended and I need to remove the CK Editor from the preloaded elements with CK Editor without knowing the

我正在一个CMS上工作,其中的元素是动态创建的,一些是预加载的,我需要将CK编辑器从那些预加载的元素中分离出来,并将CK编辑器再次附加到目标区域中的所有可编辑元素,包括预加载的元素

I'm in this loop, that gives me the target div being appended and I need to remove the CK Editor from the preloaded elements with CK Editor without knowing their Ids and name values.




   //here 'thisElement' is the array of all editable elements being appended including preloaded ones
                    var i;
                    for (i = 0; i < thisElement.length; i++) {

                      //something like this, this doesn't work
                      //  CKEDITOR.destroy(thisElement.get(a));

                      //or something like this, this doesn't work
                       // CKEDITOR.editable(thisElement.get(i));

                        CKEDITOR.inline(thisElement.get(i));

                        for (name in CKEDITOR.instances) {
                            delete CKEDITOR.instances[name];
                        }
                    };
我在这个循环中,这给了我要追加的目标div,我需要使用CK-Editor从预装元素中删除CK-Editor,而不知道它们的id和name值。
//这里的“thisElement”是附加的所有可编辑元素的数组,包括预加载的元素
var i;
对于(i=0;i

我怎样才能做到这一点呢?

我也做了类似的事情。我从表中添加和删除绑定到集合的条目的行。因此,我必须在DOM中重新设置索引的种子,并删除和重新附加所有的编辑器

下面是对我有用的,但它确实从当前页面中删除了所有编辑器

编辑:添加了检查,以查看CKEditor名称是否在DOM元素名称数组中

  var domElements = ["element1", "element2"];

        for (instance in CKEDITOR.instances) {
            if (CKEDITOR.instances.hasOwnProperty(instance)) {
                if (jQuery.inArray(CKEDITOR.instances[instance].name, domElements) !== -1) {
                    CKEDITOR.instances[instance].destroy();
                }
            }
        }

希望这能有所帮助

谢谢你的回答,不过我只需要将CK编辑器与“thissement”中的可编辑元素分离,即删除的元素。有什么想法吗?@ZeeshanAdil-你能展示一下这个元素中有什么吗。i、 是的,它是一些可编辑段落和标题的数组[完整的Dom元素]。当它们使用CKEDITOR.inline()删除时,我正在对它们应用CK编辑器。它们是DOMelements@ZeeshanAdil-可能是您的销毁脚本所在的位置与您有冲突。输入一些警报,确保您的销毁没有在错误的时间调用。我的编辑器初始化已在文档内部就绪。只需点击一个按钮即可销毁。