Luke
Luke

Reputation: 21

Add single word attribute to the output of a component

I'd like to output as a single word attribute in html. The source is an AEM dialog that's structured as a radio group.

<items jcr:primaryType="nt:unstructured">
    <colorpref jcr:primaryType="nt:unstructured"                        
        sling:resourceType="granite/ui/components/coral/foundation/form/radiogroup"
        fieldLabel="Choose Color Pref"
        name="./scheme" vertical="{Boolean}true">
        <items jcr:primaryType="nt:unstructured">
            <primary jcr:primaryType="nt:unstructured"
                     text="Primary"
                     value="primary"/>
            <secondary jcr:primaryType="nt:unstructured"
                       text="Secondary"
                       value="secondary"/>
            <parentcolor jcr:primaryType="nt:unstructured"
                         text="Use Parent Color"
                         value="useparentcolor"/>
       </items>
   </colorpref>
</items>

And then from the dialog output the value of the selected value as a single word

<element selectedoption ...

instead of

        <element selectedoption='true' ...

The code I'm using to write the attribute is

  "${button.scheme @ context='html'}"

but that isn't creating any text. I've replaced the html in context phrase with attribute and text but neither of those work.

I'm using javascript to build the model that's referenced by button in the code. So how do I output a single word attribute from the dialog in AEM?

Upvotes: 0

Views: 104

Answers (1)

Luke
Luke

Reputation: 21

The solution is to use the data-sly-attribute.
data-sly-attribute.danger="${ insert test here }" which will output just the single word danger in the element.

Upvotes: 2

Related Questions