In order to create a new tag editor, you must provide an implementation for the inspectTag(), validateTag(), and applyTag() functions. For an example of an implementation, see Create a tag editor UI.
The function is called when the tag editor first appears. The function receives as an argument the tag that the user is editing, which is expressed as a dom object. The function extracts attribute values from the tag that is being edited and uses these values to initialize form elements in the tag editor.
<crfweather zip = “94065”/>
If the editor contains a text field for editing the zip attribute, the function needs to initialize the form element so that the user sees the actual ZIP code in the text field, rather than an empty field.
The following code performs the initialization:
function inspectTag(tag) { document.forms[0].zip.value = tag.zip }
When a user clicks on a node in the tree control or clicks OK, the function performs input validation on the currently displayed HTML form elements.
Dreamweaver expects a Boolean value: true if the input for HTML form elements is valid; false if input values are not valid.
When the user creates a table, a negative integer is entered for the number of table rows. The validateTag() function detects the invalid input, displays an alert message, and returns a false value.
When the user clicks OK, Dreamweaver calls the validateTag() function. If the validateTag() function returns a true value, Dreamweaver calls this function and passes the dom object that represents the current tag (the tag that is being edited). The function reads the values out of the form elements and writes them into the dom object.
Continuing the cfweather example, in the following code, if the user changes the ZIP code from 94065 to 53402, in order to update the user’s document to use the new ZIP code, the dom object must be updated:
function applyTag(tag) { tag.zip = document.forms[0].zip.value }