Holds the data of the model. A fx-model may have as many fx-instance elements as
necessary.
| Name | Description | default |
|---|---|---|
| credentials | sets credentials policy - one of ‘omit’, ‘same-origin’ or ‘include’ | same-origin |
| id | id of the instance for addressing in refs | default |
| shared | boolean attribute to signal that the instance is shared with nested Fore elements | |
| src | url to load instance from via http get. This may have static params but cannot use dynamic parameters. See fx-submission for if required. | |
| type | ‘xml’, ‘json’, ‘html’ or ’text’. Inline data requires html (or json/text); xml instances must be loaded via src | xml |
| xpath-default-namespace | namespace to be used with unprefixed XPathes | emtpy |
When using multiple instances you must add an id attribute to each instance that is NOT the first in document order. The first is known as the default instance and doesn’t need an explicit id but can be accessed with instance() or `instance(‘default’).
You can still however add an id (e.g. ‘myCustomId’) if you like and instance() or instance('myCustomId') will return it.
A data structure can be given inline or be loaded via the src attribute.
Since version 5.0.0 inline data is no longer supported for type="xml" (the default). The browser’s HTML parser
processes everything inside <fx-instance> before Fore sees it: names are lowercased, namespaces do not work and
self-closing elements are expanded. Fore therefore ignores inline content of an xml instance, logs an error and
fires a message event with level error.
Choose one of:
type="html" for inline data. Write it as HTML: lowercase names, explicit closing tags (never />).
The elements are in the XHTML namespace.<fx-instance type="html">
<data>
<item></item>
</data>
</fx-instance>
src to load a proper XML document from an external file, which keeps case, namespaces and self-closing elements.<fx-instance src="countries.xml"></fx-instance>
type="json" and type="text" can also be given inline without limitations.
Add type="html" to every <fx-instance> that has inline content and no type, or move the data to an external
file loaded with src.
src attributeWhen static data files shall be loaded you can use the src attribute which may also have some static attributes. However, as instance data can
be accessed not before all have been loaded you cannot have dynamic parameters that refer to other nodes.
If that is required you have to use the fx-submission element and use a ‘get’ request with replace="instance" to load the data. The submission is then usually fired on model-construct-done. Examples can be found in the demos.
By adding an shared attribute to an <fx-instance> that instance is shared with nested <fx-fore> elements and can be accessed and mutated as usual.
This can be used if multiple nested Fore elements represent different views but you want to share some common data.
Another possible use case is to separate the model from the UI part and put them in different files for dynamic assembly at runtime (see documentation under ‘modularization’).
In addition to ‘http’, ‘https’ further URI schemes are: