Expand my Community achievements bar.

SOLVED

data attribute in dropdownshowhide.js

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Level 4

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

View solution in original post

2 Replies

Avatar

Correct answer by
Level 4

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

Avatar

Level 2

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>