【问题标题】:Redactor show only one instance at a time编辑器一次只显示一个实例
【发布时间】:2023-03-30 16:12:01
【问题描述】:

我有一个条件,我必须在整个文档中搜索特定类,然后单击该类来初始化编辑器。

我已经通过遍历 html 和

$(".contenteditor").redactor({
    toolbarExternal: '.commoneditor',
    toolbarFixed: true,
    focus       : true,
    imageUpload : 'image_upload.php',
    css         : "http://localhost/template/css/basictemplatepage.css",
});

假设有多个元素具有相同的类并且两者都应该触发编辑器。在这种情况下,我想出了不止一个无法正常工作的 redactor 实例。我只想销毁所有以前的实例并只保留一个编辑器实例。我该怎么做??

【问题讨论】:

    标签: jquery redactor


    【解决方案1】:

    您可以使用引用clicked 元素的this 关键字来实例化click 上的编辑器。

    $(".contenteditor").on('click', function(event){
    
    $(this).redactor({
        toolbarExternal: '.commoneditor',
        toolbarFixed: true,
        focus       : true,
        imageUpload : 'image_upload.php',
        css         : "http://localhost/template/css/basictemplatepage.css",
    });
    });
    

    【讨论】:

    • 我几乎做了同样的事情 $(this).addClass("contenteditor");然后使用这个添加的类调用编辑器..
    猜你喜欢
    • 1970-01-01
    • 2013-11-27
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多