- concrete5 Cookbook
- David Strack
- 191字
- 2021-08-13 16:16:01
Including JavaScript in block forms
When adding or editing blocks, it is often desired to include more advanced functionality in the form of client-side JavaScript. concrete5 makes it extremely easy to automatically add a JavaScript file to a block's editor form.
Getting ready
We will be working with the block that was created in the first recipe of this chapter. If you need to catch up, feel free to download the code from this book's website.
How to do it...
The steps for including JavaScript in block forms are as follows:
- Open your block's directory.
- Create a new file called
auto.js
. - Add a basic alert function to
auto.js
:alert('Hello!');
- Visit a page that contains your block.
- Enter edit mode and edit the block.
- You should see your alert message appear as shown in the following screenshot:
How it works...
concrete5 automatically looks for the auto.js
file when it enters add or edit mode on a block. Developers can use this to their advantage to contain special client-side functionality for the block's edit mode.
See also
- The Including JavaScript in the block view recipe
- The Including CSS in the block view recipe
推薦閱讀
- FuelPHP Application Development Blueprints
- Python數據可視化:基于Bokeh的可視化繪圖
- Python數據分析基礎
- Mastering Spring MVC 4
- Raspberry Pi for Secret Agents(Third Edition)
- 軟件品質之完美管理:實戰經典
- Android Wear Projects
- Linux C編程:一站式學習
- Android驅動開發權威指南
- Mastering AWS Security
- Python期貨量化交易實戰
- Android Development Tools for Eclipse
- Android系統下Java編程詳解
- AutoCAD基礎教程
- JavaScript重難點實例精講