You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
You can include the javascript file in a module view by using the Assets library in bonfire (codeigniter). Suppose you want to include a javascript file called ‘custom_edit_account.js’ inside the ‘account’ module.
So follow these steps:
Create a folder called ‘assets’ in account module. So the path of assets folder is /bonfire/modules/account/assets.
Inside the assets folder created in step 1,create a ‘js’ folder so that the path of the js folder is /bonfire/modules/account/assets/js
Now place the custom_edit_user.js inside the ‘js’ folder. So the path is /bonfire/modules/account/assets/js/ custom_edit_ account.js
Now inside the controllers action whose view you want to include the js file, add this code in bold shown in the example below,
public function edit()
{
$output['toolbar_title'] = 'Edit Account';
Here Assets::clear_cache() function clears the assets cache before regenerating the javascript file. This is necessary if you want to use different javascript for different views of the same module. The Assets::add_module_js() function adds the javascript file in the rendered view file (here admin/custom/edit_account') . the first parameter of the add_module_js() function is the module name where the javascript is to be included and second parameter is the path of the js relative to the modules ‘assets’ folder.
You can also include module specific css in the same way. Just place the css file in the assets ‘css’ folder in module(/bonfire/modules/account/assets/js/ account.css for example) and call the function Assets::add_module_css() from the controller.
public function edit()
I'm agree with you.
sometimes my form need a lot of js for date picker and any other components. But I don't want load it when I just need to show the table of data.
zoliszabo
added a commit
to zoliszabo/Bonfire
that referenced
this issue
Jul 26, 2017
Can the bonfire core to improve this issue ?
I has spent too much time to solve this issue until I found the following article
http://speakingofcomputers.blogspot.com/2012/05/bonfire-adding-javascript-and-css-to.html
You can include the javascript file in a module view by using the Assets library in bonfire (codeigniter). Suppose you want to include a javascript file called ‘custom_edit_account.js’ inside the ‘account’ module.
So follow these steps:
public function edit()
{
$output['toolbar_title'] = 'Edit Account';
Here Assets::clear_cache() function clears the assets cache before regenerating the javascript file. This is necessary if you want to use different javascript for different views of the same module. The Assets::add_module_js() function adds the javascript file in the rendered view file (here admin/custom/edit_account') . the first parameter of the add_module_js() function is the module name where the javascript is to be included and second parameter is the path of the js relative to the modules ‘assets’ folder.
{
$output['toolbar_title'] = 'Edit Account';
}
The text was updated successfully, but these errors were encountered: