Adminhtml JavaScript – How to Add Custom JavaScripts to Adminhtml Config Page

adminhtmljavascript

I am working on a custom Magento extension.
I have created already a page in the admin panel where you can save some settings for the extension.

The url of the page where you can edit the module settings is looking like this:

http://mymagento.com/index.php/admin/system_config/edit/section/vivasparser/

Here is my config.xml file:

<config>
    <modules>
        <VivasIndustries_Smartparser>
            <version>0.1.0</version>
        </VivasIndustries_Smartparser>
    </modules>
    <global>
        <models>
            <smartparser>
                <class>VivasIndustries_Smartparser_Model</class>
            </smartparser>
        </models>
        <helpers>
            <smartparser>
                <class>VivasIndustries_Smartparser_Helper</class>
            </smartparser>
        </helpers>
     </global>
    <adminhtml>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <vivasparser>
                                            <title>vivasparser - All</title>
                                        </vivasparser>
                                    </children>
                                </config>
                            </children>
                        </system>
                    </children>
                </admin>
            </resources>
        </acl>
          <layout>
            <updates>
              <smartparser>
                <file>smartparser.xml</file>
              </smartparser>
            </updates>
          </layout>
    </adminhtml>     
</config>

Here is my smartparser.xml file:

<layout>
  <adminhtml_catalog_product_edit
    <reference name="head">
      <action method="removeItem"><type>js</type><name>prototype/prototype.js</name></action>
      <action method="addJs"><script>my_extension/jquery.js</script></action>
      <action method="addJs"><script>my_extension/colorpicker.js</script></action>
      <action method="addJs"><script>prototype/prototype.js</script></action>
    </reference>
  </adminhtml_catalog_product_edit>
</layout>

Why the javascripts are not loaded ?
I am trying to find colorpicker.js in the output HTML source of the page but there is no such thing loaded anywhere.

Can you help me out load these javascripts into my admin panel config page ?

Thanks in advance!

Best Answer

in smartparser.xml the layout handle should be adminhtml_system_config_edit instead of adminhtml_catalog_product_edit.
Also you forgot a > on the line <adminhtml_catalog_product_edit.