0

In Created Custom tab in magento. Image not upload in editor. That display error like Uncaught ReferenceError: Mage is not defined

in Edit.php file

protected function _prepareLayout()
{
 // added this code    
    if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { 
        $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); 
        $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); 
    } 
}

in my Form

$configSettings = Mage::getSingleton('cms/wysiwyg_config')->getConfig(
                        array(
                        'add_widgets' => false,
                        'add_variables' => false,
                        'add_images' => true,
                        'files_browser_window_url'=>    $this->getBaseUrl().'admin/cms_wysiwyg_images/index/',
));
1

Put the below code in app\design\adminhtml\default\default\layout\[your_layout_file_name].xml

     <default>
         <reference name="head">
             <action method="setCanLoadExtJs"><flag>1</flag></action>
             <action method="addJs"><script>mage/adminhtml/variables.js</script></action>
             <action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
             <action method="addJs"><script>lib/flex.js</script></action>
             <action method="addJs"><script>lib/FABridge.js</script></action>
             <action method="addJs"><script>mage/adminhtml/flexuploader.js</script></action>
             <action method="addJs"><script>mage/adminhtml/browser.js</script></action>
             <action method="addJs"><script>prototype/window.js</script></action>
             <action method="addJs"><script>events/adminhtml/product.js</script></action>
             <action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
         </reference>
     </default>
1

Thank you for all your Answers. but i found my solution in my code. just remove some code in my form

$configSettings = Mage::getSingleton('cms/wysiwyg_config')->getConfig();

and add js files link in your module layout xml file.

<adminhtml_modulename_edit>
<reference name="head">
<action method="addItem"><type>js</type><name>mage/adminhtml/wysiwyg/tiny_mce/setup.js</name></action>
<action method="addItem"><type>js</type><name>tiny_mce/tiny_mce.js</name></action>
        <action method="addItem"><type>js</type>
</reference>
<update handle="editor"/>
</adminhtml_modulename_edit>
0

It looks js/mage/cookies.js is missing. It defines the Mage Javascript class.

if (!window.Mage) var Mage = {};

add this in your xml file.

<action method="addJs"><script>mage/cookies.js</script></action>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.