【问题标题】:No such method "destroy" for Redactor没有这样的方法“破坏” Redactor
【发布时间】:2018-04-02 08:27:32
【问题描述】:

我不确定“方法”这个词是否与来自 Redactor 的函数或类有关。但我正试图通过$('#id').redactor('destroy') 摧毁编辑器。该代码在创建/实例化编辑器时有效,但在我销毁它之后立即给出错误 No such method "destroy" for Redactor,(因为它已经被销毁)。在某种程度上,我想在销毁之前检查该方法是否存在;就像来自javascript的那个来检查函数是否存在,比如typeof $(#id).redactor === 'function',我也尝试使用$(#id).hasClass($(#id).redactor('destroy')),但仍然导致错误。

所以我不确定如何检查该方法是否存在,这样我只会在创建/实例化编辑器时销毁它。

为了贾达夫先生:

这是我的 Instructions.js

Ext.define('myNamespace', {
    extend: 'Ext.container.Container',
    alias : 'widget.instructionstab',

    requires:[
        'myCommonFunctions',
    ],
    margin: '5 5 5 5',
    layout: {
        type: 'vbox',
        align: 'stretch'
    },
    initComponent: function() {
        var me = this,
            cfg = cfg || {};

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'textareafield',
                    flex: 1,
                    itemId: 'txtHeaderComment',
                    fieldLabel: 'Header Comment',
                    enableDrillDown: true,
                },
                {
                    xtype: 'textareafield',
                    flex: 1,
                    itemId: 'txtFooterComment',
                    fieldLabel: 'Footer Comment',
                    enableDrillDown: true
                }
            ]
        }, cfg);

        me.callParent(arguments);
    }

});

myCommonFunctions:

createRadEditor: function(el) {
        var me = this;

        var fn = function () {
            $('#' + el.inputId).redactor({
                buttons: ['bold', 'italic', 'underline', 'deleted', 'alignleft', 'aligncenter', 'alignright', 'unorderedlist', 'orderedlist', 'outdent', 'indent', 'image', 'video', 'table', 'link', 'horizontalrule', 'html', 'fullscreenwindow'],
                plugins: ['fontcolor', 'fontfamily', 'fullscreenwindow'],
                clipboardUpload: true,
                clipboardUploadUrl: './somelink/setimage',
                blurCallback: function(e){
                    console.log("ASDF"); // i'm still trying out something
                }
            });

            $('#'+ el.inputId).redactor('setTextEditorHeight');
            $('#'+ el.inputId).attr("id",el.config.itemId);
        };
        var task = Ext.create('Ext.util.DelayedTask', fn);
        task.delay(500);
    },

我的视图:

{
    xtype: 'panel',
    itemId: 'pnlInstructions',
    layout: 'fit',
    title: 'Instructions',
    items: [
        {
            xtype: 'instructionstab'
        }
    ]
},

我在这里使用https://imperavi.com/redactor/docs/ 的一些文档来获取编辑器的属性。

【问题讨论】:

  • ExtJS 代码在哪里?
  • 我的项目是在 ext Js 中创建的。我只是没有放置 Ext js 的代码,但我放置了标签,因为我可能不知道 Ext Js 中可以用于替换的东西jquery,但重要的部分只是 jquery 部分......但如果你真的需要我可以提供......
  • 如果你正在使用 ExtJS,所以尝试使用 ExtJS 方法来获取组件而不是 jquery。
  • 我编辑了信息。请 Jadhav 先生 .. 告诉我使用 extjs 方法获取组件的区别以及它将如何帮助我解决禁用编辑器的问题
  • JC 先生请试试这个$('#id').destroyEditor() 这会奏效。参考link 和请检查这个FIDDLE

标签: javascript extjs


【解决方案1】:

如果你想销毁 redactor,那么你应该使用:

$("#editor").redactor("core.destroy");

【讨论】:

    猜你喜欢
    • 2018-12-14
    • 2015-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-11
    • 2017-10-02
    • 1970-01-01
    • 2014-02-24
    相关资源
    最近更新 更多