I want to load jQuery in admin panel. How can I do this programmatically without creating layout XML files in /app/design/adminhtml/default/default/layout/
? Method with layout XML is described in this thread: https://stackoverflow.com/questions/12799838/how-to-load-a-js-file-on-magento-admin-dashboard
Is there any way to do this programmatically in my custom module?
The module adds some new form fields which can be used on admin pages under System->Configuration. And there I need jQuery to be loaded.
EDIT
In my module I have this custom field in which I need to use jQuery:
class Company_Helloworld_Block_Adminhtml_Mybutton extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
//...here add some custom button functionality
}
}
Best Answer
You can access the layout programmatically via the
getLayout
method. Your block class would look something like this