Potential Extension: Adding Attributes to the Template

Big applications can always be made bigger. This section is devoted to showing you how to add attributes to the image template, giving you greater control over the generated code. For the sake of simplicity, I’ll show you how to add the IMG attributes HSPACE and VSPACE. The procedure involves these six steps:

  1. Add the new fields in the default template.

  2. Create an array for its values in setArrays().

  3. Capture the new default values.

  4. Add text fields in the image template in generateEntryForm().

  5. Reference and assign the new attribute values in genJavaScript().

  6. Generate the HTML required to display the attributes in genJavaScript().

Get JavaScript Application Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.