How to get checked items of aui-dropdown2 checkboxes

Hi,
i like to get all checked items of a dropdown2. My dropdown:

<div id="dropdown" class="aui-dropdown2 aui-style-default">
    <div id="sectionone" class="aui-dropdown2-section">
        <div class="aui-dropdown2-heading aui-dropdown2-checkbox interactive checked">
            Heading1
        </div>
        <ul>
             #foreach($value in $values)
                <li>
                    <a class="aui-dropdown2-checkbox interactive">$value</a>
                </li>
            #end
        </ul>
    </div>
    <div id="sectiontwo" class="aui-dropdown2-section">
        <div class="aui-dropdown2-heading aui-dropdown2-checkbox interactive">
            Heading2
        </div>
        <ul>
            #foreach($othervalue in $othervalues)
                <li>
                    <a class="aui-dropdown2-checkbox interactive">$othervalue</a>
                </li>
            #end
        </ul>
    </div>
</div>

Now i like to get the text of all checked items. The dropdown2 documentation did not help.

Thanks in advance.

Hi Markus,

I quickly tried to get the text of “checked” items on the AUI sandbox here: AUI - Documentation

And it works! Specifically you can use jQuery to extract and check the markup:

jQuery('.aui-dropdown2-radio').each(function(i, e){
    if (jQuery(e).attr('class').indexOf('checked') > 0) {
      console.log(jQuery(e).text());
    }
});

This is quickly hacked together at the sandbox page so there may be a more efficient way to do it but you get a feeling for it I hope.

4 Likes

Thank you for the quick response, i’m quite new to this. That’s something i can work with.

1 Like