- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Adding JavaScript file
I am developing a module. I am new in module development.
Now I need to know how to add JavaScript file when someone developing a module ??
The conditions are as below:
1. When the module installed then the JavaScript file will be loaded.
2. When the module uninstalled then the JavaScript file will be not loaded.
3. When the module disabled through XML file of app/etc/modules directory then the JavaScript file will be not loaded.
4. When the module disabled through enable/disable option of the module then the JavaScript file will be not loaded.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Adding JavaScript file
- If your module is installed and the javascript is part of the module then your JS gets loaded (unless 4. has conditions).
- If your module is NOT installed, then there's no JS to be loaded.
- If your module is disabled from bootstrap XML, then your javascript do not get loaded as the layout xml that loads it do not get loaded either.
- There's an ifconfig attrbute to achieve it. Check out this page: http://magento.stackexchange.com/questions/3418/conditionally-show-hide-blocks-in-layout-xml
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Adding JavaScript file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Adding JavaScript file
When you create your own extension one thing you want to do is to declare a layout file. In the layout file you can define layout updates, such as additional JS/CSS files to be loaded. The page I linked explains some of those things.