The 'transform' command
Generic use :
<div id="identifier" data-command="transform" data-template="path/to/template"/>
Implicit form use :
<div id="identifier" data-template="path/to/template"/>
The 'transform' command creates an AXEL editor and attaches it to an HTML element.
The implicit form also directly loads the XTiger XML template specified in the data-template
attribute (using Ajax) and replaces the host element content (a <div>
in the synopsis) by the editor generated from the template transformation immediately after page load.
The editor object is accessible with the $axel.command.getEditor(key)
function where key is the host element identifier. The returned editor supports the following methods :
-
attr(name)
: to get the value of the attribute name of the host element -
transform
: to transform the template and generate a new editor -
reset
: to reset the editor (same as loading an empty document into it) -
trigger(name, source)
: to trigger a DOM event at the host element
The editor is compatible with the $axel
wrapped set. So for instance once transformed, you can also use $axel('#identifier').load(url)
or $axel('#identifier').xml()
to respectively load and serialize XML content to or from it.
In the non implicit form you need to programmatically call transform
at some point to generate the editor.
With an optional data-src
attribute :
<div id="identifier" data-template="path/to/template" data-src="path/to/source/XML"/>
in addition, the editor will load right after transformation the XML data specified by the data-src
attribute into the editor.
Special syntax for in-place transformation of the full document :
<body id="identifier" data-template="#">
...
</body>
the syntax above transforms the content of the <body>
element into an editor. Of course it only works if the document is an XTiger XML template.
Host element identifier : you must set an id
attribute on the host element, it will be used to target the generated editor into other AXEL-FORMS commands.
Error messages
When the template fails to load or to transform, or XML data fails to load, the command currently prints an error message using alert. Find a way to customize this.