Magento所见即所得的编辑器按钮不起作用 [英] Magento WYSIWYG editor button not working

查看:110
本文介绍了Magento所见即所得的编辑器按钮不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在magento管理>产品页面中,我单击所见即所得"按钮以打开tiny_mce编辑器,但没有任何反应.我使用Firebug检查了页面控制台,但出现以下错误:

in magento administration > product page, I click on the WYSIWYG button to open the tiny_mce editor, but nothing happens. I checked the page console using Firebug and I'm getting the following error:

catalogWysiwygEditor未定义

,此错误适用于此部分代码:

and the error applies to this part of code:

<button  id="id_24edece0c646ca9ab683ec22d0479550" title="WYSIWYG Editor" type="button" class="scalable btn-wysiwyg" onclick="catalogWysiwygEditor.open('http://website.com/index.php/admin/catalog_product/wysiwyg/key/0126e7041c67954f9612a311681b7915/', 'description')" style=""><span><span><span>WYSIWYG Editor</span></span></span></button>

反正有解决此问题的方法吗?

Is there anyway to fix this?

-------更新-----

-------UPDATE-----

我发现发生这种情况的原因是 app/design/adminihtml/default/default/template/catalog/wysiwyg/js.phtml 文件未未加载 >.

I found that the reason for this happening is that the app/design/adminihtml/default/default/template/catalog/wysiwyg/js.phtml file is not loaded.

我只是找不到原因.应该基于app/design/adminihtml/default/default/layout/catalog.xml文件加载该文件:

I just can't find why though. It should be loaded based on the app/design/adminihtml/default/default/layout/catalog.xml file:

<adminhtml_catalog_product_edit>
    ...
    <reference name="js">
        <block type="adminhtml/catalog_product_edit_js" template="catalog/product/js.phtml" name="catalog_product_js"></block>
        <block type="core/template" name="catalog.wysiwyg.js" template="catalog/wysiwyg/js.phtml"/>
    </reference>
</adminhtml_catalog_product_edit>

有什么想法吗?

推荐答案

我为此找到的唯一解决方案是直接在 app/design/adminihtml/default/default/template中添加缺少的javascript代码/catalog/product/edit.phtml 文件.这不是一个优雅的解决方案,但它是唯一有效的解决方案:

The only solution I found for this one was to add the missing javascript code, directly in the app/design/adminihtml/default/default/template/catalog/product/edit.phtml file. It's not an elegant solution, but it's the only one taht worked:

<script type="text/javascript">
//<![CDATA[

Window.keepMultiModalWindow = true;
var catalogWysiwygEditor = {
    overlayShowEffectOptions : null,
    overlayHideEffectOptions : null,
    open : function(editorUrl, elementId) {
        if (editorUrl && elementId) {
            new Ajax.Request(editorUrl, {
                parameters: {
                    element_id: elementId+'_editor',
                    store_id: '<?php echo $this->getStoreId() ?>'
                },
                onSuccess: function(transport) {
                    try {
                        this.openDialogWindow(transport.responseText, elementId);
                    } catch(e) {
                        alert(e.message);
                    }
                }.bind(this)
            });
        }
    },
    openDialogWindow : function(content, elementId) {
        this.overlayShowEffectOptions = Windows.overlayShowEffectOptions;
        this.overlayHideEffectOptions = Windows.overlayHideEffectOptions;
        Windows.overlayShowEffectOptions = {duration:0};
        Windows.overlayHideEffectOptions = {duration:0};

        Dialog.confirm(content, {
            draggable:true,
            resizable:true,
            closable:true,
            className:"magento",
            windowClassName:"popup-window",
            title:'WYSIWYG Editor',
            width:950,
            height:555,
            zIndex:1000,
            recenterAuto:false,
            hideEffect:Element.hide,
            showEffect:Element.show,
            id:"catalog-wysiwyg-editor",
            buttonClass:"form-button",
            okLabel:"Submit",
            ok: this.okDialogWindow.bind(this),
            cancel: this.closeDialogWindow.bind(this),
            onClose: this.closeDialogWindow.bind(this),
            firedElementId: elementId
        });

        content.evalScripts.bind(content).defer();

        $(elementId+'_editor').value = $(elementId).value;
    },
    okDialogWindow : function(dialogWindow) {
        if (dialogWindow.options.firedElementId) {
            wysiwygObj = eval('wysiwyg'+dialogWindow.options.firedElementId+'_editor');
            wysiwygObj.turnOff();
            if (tinyMCE.get(wysiwygObj.id)) {
                $(dialogWindow.options.firedElementId).value = tinyMCE.get(wysiwygObj.id).getContent();
            } else {
                if ($(dialogWindow.options.firedElementId+'_editor')) {
                    $(dialogWindow.options.firedElementId).value = $(dialogWindow.options.firedElementId+'_editor').value;
                }
            }
        }
        this.closeDialogWindow(dialogWindow);
    },
    closeDialogWindow : function(dialogWindow) {
        // remove form validation event after closing editor to prevent errors during save main form
        if (typeof varienGlobalEvents != undefined && editorFormValidationHandler) {
            varienGlobalEvents.removeEventHandler('formSubmit', editorFormValidationHandler);
        }

        //IE fix - blocked form fields after closing
        $(dialogWindow.options.firedElementId).focus();

        //destroy the instance of editor
        wysiwygObj = eval('wysiwyg'+dialogWindow.options.firedElementId+'_editor');
        if (tinyMCE.get(wysiwygObj.id)) {
           tinyMCE.execCommand('mceRemoveControl', true, wysiwygObj.id);
        }

        dialogWindow.close();
        Windows.overlayShowEffectOptions = this.overlayShowEffectOptions;
        Windows.overlayHideEffectOptions = this.overlayHideEffectOptions;
    }
};

//]]>
</script>

这篇关于Magento所见即所得的编辑器按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆