- 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
推薦閱讀
- 軟件項目估算
- Building a Home Security System with Raspberry Pi
- Architecting the Industrial Internet
- 實用防銹油配方與制備200例
- C語言程序設計實訓教程
- Spring Cloud、Nginx高并發核心編程
- Java性能權威指南(第2版)
- SQL Server 2012數據庫管理與開發項目教程
- C語言程序設計
- 速學Python:程序設計從入門到進階
- JQuery風暴:完美用戶體驗
- Mudbox 2013 Cookbook
- Java程序設計教程
- Learning iOS Penetration Testing
- Getting Started with Windows Server Security