Generating a unique ID for a view
In some situations you might want to use the
ID
attribute for your DOM
elements within a view. However, all DOM IDs must be globally unique. For example, during
collaboration the default highlighting behavior is implemented based on a unique DOM ID. To ensure a
unique ID, you can use the $$viewDOMID$$
placeholder keyword. At run time, this
keyword will be replaced by the view DOM ID.
About this task
$$viewDOMID$$
in your view implementation, you can ensure that all of your DOM
elements have DOM IDs that are globally unique. For example, you might want to highlight an element
such as a button at run time. You can create your element using custom HTML, and assign the DOM ID
attribute by prefixing with $$viewDOMID$$
. When the view is rendered, the
$$viewDOMID$$
attribute will be replaced by a unique ID (the DOM ID of the rendered
view) for the element. Note: Stock controls such as Vertical Layout
might shift the scope for the
$$viewDOMID$$
attribute, which can result in
different values for $$viewDOMID$$
in complex views. If you assume that
$$viewDOMID$$
is equal to the context.element.id
, you might use an
unexpected value.Procedure
To generate a unique ID:
- Open the view.
- Switch to the Layout page.
- Create a custom HTML view.
- Enter custom HTML code, and use
$$viewDOMID$$
in theid
attribute:<div id="$$viewDOMID$$_myId1"> <span id="$$viewDOMID$$_myId2"></span> <input id="$$viewDOMID$$_myId3" type="button" class="Jquerybutton" name="jbtnName" value="default"></input> </div>
Note: To avoid potential conflicts, use a meaningful suffix after$$viewDOMID$$
, for example$$viewDOMID$$_buttonDiv
.