data attribute in dropdownshowhide.js | Community
Skip to main content
New Participant
March 27, 2018
Solved

data attribute in dropdownshowhide.js

  • March 27, 2018
  • 2 replies
  • 1979 views

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.
Best answer by wimsymonsvrt

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
New Participant
March 28, 2018

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>

wimsymonsvrtAccepted solution
New Participant
March 28, 2018

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