Grabbing the block name in Javascript and other model questions for UE
Good morning - I've been doing some block development with UE and as I've been going through this, I wanted to ask a few questions.
- In a recent GEM webinar, there was reference to appending foreground_ and background_ to block names and this would affect the grouping of divs in EDS. I tried to find documentation around this and other useful things to know when modelling, but I couldn't find it.
- When modelling the block, we assign names in the JSON, is this name attribute available to use in the Javascript?
- Reason is, if I have a model with multiple text types, these are outputted a P tag in a div. But I can't see a logical way to decorate specific children[n] of a block without knowing what I am decorating.
- Simple Example: Block has Author Text and Summary Text block types. If I don't add a Author, but add a Summary, I don't want the Summary styled like the Author.
- What I would like to do, is add an ID to the P tags which corresponds with the block name
<div><p id="authorName-3D-printing-with-tim-lavelle">Author Name</p></div>
<div><p id="summary-3D-printing-with-tim-lavelle">Author Name</p></div>
- Is there a better way to handle restricting block component types from rendering to the DOM?
- Example: I create a select type component in a block to handle Style selections
{
"component": "select",
"name": "teaserClassName",
"value": "",
"label": "Class",
"valueType": "string",
"options": [
{
"name": "default",
"value": ""
},
{
"name": "Card",
"value": "card"
},
{
"name": "Banner",
"value": "banner"
}
]
}
- As this is a component block, the selected value is rendered in the DOM and would essentially be indexed and I wouldn't want that.
- Additionally, is there a way to block it from rendering, without having to use the JS to remove() it after it's been sent to the DOM already.
- This same question would apply for component type boolean as it outputs the boolean value to the EDS DOM.
Hope these aren't too many questions in one thread and thanks for stopping by and reading.
Cheers
Tim