Skip to main content
Skip table of contents

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. Both content-replace and content-target secondary attributes have their default values.            

  • If the secondary attribute model-editable is undefined or resolves into true, does the same as contenteditable with its primary attribute value set to "true". The resulting Map of model's secondary attribute model-editorconfig is used as the value for contenteditable's secondary attribute contenteditable-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 into true, the host element is transformed into an input element. The resolved value of the primary attribute is set as the value of the input, unless the value is null, 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 that model-editable is false 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 into false, the host element will remain as a span, but has its text content set to the resolved value of model's primary attribute. However, if the resolved value is null, 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 contenteditable's contenteditable-defaults attribute, which allows the other secondary attributes of that content command to be defined with entries in the Map.

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 false, the value of model's primary attribute will appear as the content, but will not be editable.

Note that this attribute can be overridden by the composeContent command's editable attribute, which if false, sets the contents as uneditable regardless of this attribute's value.  

If not defined and composeContent is not making everything uneditable, the value defaults to true allowing users to edit the contents.

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.

CODE
<div dyn-model="sampleContent" dyn-model-editorconfig="editorAttributes"/>

The above is basically equivalent to:

CODE
<div id="sampleContent" value-type="html" dyn-content="sampleContent" dyn-contenteditable="true" dyn-contenteditable-defaults="editorAttributes"/>
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.