on 2024 Sep 26 10:38 AM
Hello,
I'm finding some trouble in SAPUI5 to get `data-` attributes written to DOM. I need a simple implementation as I will need to manually add in several XML elements this data attribute
I'm aware that I could use `<CustomData />`, but the perfect implementation for my need is to create a new XML namespace for http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1 and then evoke it on the element, as in:
<Button namespace:testid="foobar" />
The problem is that it's not rendering on DOM and I just can't find any more ways to tackle this on the documentation, and even here.
This is a short example of my implementation, and the problem: https://jsfiddle.net/kpvnw760/4/
If you notice, once you run the code linked above, and if you do:
document.querySelector("button").dataset
It will only list "sapUI" and "ui5Accesskey", never "testId" nor "foobar".
The documentation reference I'm using is: https://ui5.sap.com/#/topic/91f0c3ee6f4d1014b6dd926db0e91070 (section: "Use in XML Views").
Thank you a lot, in advance!
Request clarification before answering.
The reason is that Shorthand for customdata does not write those attributes to DOM.
https://ui5.sap.com/#/topic/1ef9fefa2a574735957dcf52502ab8d0
To set the writeToDom flag in XML views, the aggregation has to be written in expanded notation.
I am also looking for a solution to this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
41 | |
15 | |
11 | |
9 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.