model
An HTML content command that is basically a combination of content and contenteditable. It has the effects of both commands on the host element, bringing content to it, making these contents editable and submitting the edited contents.
The value of this command's primary attribute defines the variable whose value is being read and possibly updated.
Generally this command should only be placed on the generic HTML block and inline elements div
and span
. The exact effects on the host element vary depending on which one it is.
If model
is set on a div
element:
Does the same as
content
with its primary attribute value as the same as model's primary attribute value. Bothcontent-replace
andcontent-target
secondary attributes have their default values.If the secondary attribute
model-editable
is undefined or resolves intotrue
, does the same ascontenteditable
with its primary attribute value set to "true". The resulting Map of model's secondary attributemodel-editorconfig
is used as the value for contenteditable's secondary attributecontenteditable-defaults
.Sets HTML attribute "id" on the host element with this command's primary attribute's non-resolved value as its value. This causes the submitted value to overwrite the original variable value that was used as content.
Sets the Dynamo HTML attribute "value-type" on the element with the value "html". This causes the submitted value to appear as a HTML value in the variable context, making certain commands react to it as HTML rather than plain text.
If model
is set on a span
element:
If the secondary attribute
model-editable
is undefined or resolves intotrue
, the host element is transformed into aninput
element. The resolved value of the primary attribute is set as the value of the input, unless the value isnull
, in which case the input displays whatever was the text content of the host element. Please note that the input element will be of fixed size and so doesn't flow well among text content - it is therefore highly suggested thatmodel-editable
isfalse
if the document this command is in is composed for a non-interactive purpose, like for PDF export.If the secondary attribute
model-editable
resolves intofalse
, the host element will remain as a span, but has its text content set to the resolved value ofmodel
's primary attribute. However, if the resolved value isnull
, the host element's current text content is not changed.Note that in both cases, a resolved value that is an empty String is treated as if the value was
null
. This behavior may be changed through the composeContent command initiating the evaluation of this command.
This command has a priority of 10.
Secondary attributes
model-editorconfig | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Map | Yes |
This attribute's resolved value is used as the value for |
model-editable | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
This attribute can be used to disable the editing capabilities. If the resolved value is Note that this attribute can be overridden by the If not defined and |
Examples
As model
is a combination of two other content commands, here is an example to show how model
does the same thing as its two components would.
<div dyn-model="sampleContent" dyn-model-editorconfig="editorAttributes"/>
The above is basically equivalent to:
<div id="sampleContent" value-type="html" dyn-content="sampleContent" dyn-contenteditable="true" dyn-contenteditable-defaults="editorAttributes"/>