data attribute in dropdownshowhide.js | Community
Skip to main content
Level 2
Mar 27, 2018 1:58 PM UTC
Solved

data attribute in dropdownshowhide.js

AEM6.3 contains /libs/cq/gui/components/authoring/dialog/dropdownshowhide/clientlibs/dropdownshowhide/js/dropdownshowhide.js

At lines 49-50 there is this code:

        // get the selector to find the target elements. its stored as data-.. attribute

        var target = $(element).data("cqDialogDropdownShowhideTarget");

AFAIK data attributes are always lowercase. This is certainly the case if the data attributes are generated via granite:data node as per Common Attributes — Granite UI 1.0 documentation

When I change the code to

        var target = $(element).data("cqdialogdropdownshowhidetarget");

my select component works correctly.

Am I missing something?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
wimsymonsvrtAccepted solution
Level 4
Mar 28, 2018 6:43 AM UTC

This is ok. Camelcase is converted into kebab-case by jquery. See https://api.jquery.com/data/#data-html5. Does the HTML reflect that?

2 replies

kristofvbAuthor
Level 2
Mar 28, 2018 1:37 PM UTC

Yes, this is correct provided I generate my data attribute using

<granite:data
  jcr:primaryType="nt:unstructured"
  cq-dialog-dropdown-showhide-target=".list-option-listfrom-showhide-target">

</granite:data>

Translate
wimsymonsvrtAccepted solution
Level 4
Mar 28, 2018 6:43 AM UTC

This is ok. Camelcase is converted into kebab-case by jquery. See https://api.jquery.com/data/#data-html5. Does the HTML reflect that?

Translate