<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Executing custom JavaScript functions in Clay dropdown component</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=113702549" />
  <subtitle>Executing custom JavaScript functions in Clay dropdown component</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=113702549</id>
  <updated>2026-04-05T11:40:04Z</updated>
  <dc:date>2026-04-05T11:40:04Z</dc:date>
  <entry>
    <title>RE: Executing custom JavaScript functions in Clay dropdown component</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113702930" />
    <author>
      <name>Jan Tošovský</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113702930</id>
    <updated>2019-05-21T18:53:48Z</updated>
    <published>2019-05-21T18:53:48Z</published>
    <summary type="html">I am able to trigger my JavaScript by replacing Clay taglib with the liferay-ui taglib. In this case I can access/alter the generated markup without problems.&lt;br /&gt;&lt;a href="https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-1/liferay-ui-icon-menus"&gt;https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-1/liferay-ui-icon-menus&lt;/a&gt;&lt;br /&gt;As the liferay-ui is AUI based, I&amp;#39;d still rather find more future-ready solution.</summary>
    <dc:creator>Jan Tošovský</dc:creator>
    <dc:date>2019-05-21T18:53:48Z</dc:date>
  </entry>
  <entry>
    <title>Executing custom JavaScript functions in Clay dropdown component</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113702548" />
    <author>
      <name>Jan Tošovský</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113702548</id>
    <updated>2019-05-21T16:49:19Z</updated>
    <published>2019-05-21T16:49:19Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;By default, all dropdown menu items for &amp;lt;clay:dropdown-actions&amp;gt; are pointing to specific URLs.&lt;br&gt;&lt;a href="https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-1/clay-dropdown-menus-and-action-menus"&gt;https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-1/clay-dropdown-menus-and-action-menus&lt;/a&gt;&lt;br&gt;I'd like to execute custom JavaScript methods instead.&lt;br&gt;&lt;img src="https://dev.liferay.com/documents/12052/2090457/clay-taglib-dropdown-actions.png/d045c336-4c12-3f9b-8a3e-130efcbaa015?version=1.0&amp;amp;t=1555707595092"&gt;&lt;br&gt;I've done some experiments, but I am stuck now.&lt;br&gt;In my DropdownDisplayContext I've tried to specify javascript:void(0) as the href, but this value is rejected during rendering the component.&lt;br&gt;So I am using a dummy value hoping I'll be able to tweak it afterwards by JavaScript: &lt;br&gt;&lt;pre&gt;&lt;code&gt;dropdownItem -&amp;amp;gt; {
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; dropdownItem.setHref("#");
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; dropdownItem.setLabel("Hide Group");
});
&lt;/code&gt;&lt;/pre&gt;However, by the time of executing my JavaScript any clay component markup doesn't seem to be injected into DOM yet, so I cannot neither modify href attribute or attach event listeners to the menu items.&lt;br&gt;So tweaking clay taglib outcome afterwards sounds as a bad idea.&lt;br&gt;I'd like to avoid creating dropdown menu from scratch (expecting browser compatibility issues, responsivity challenges etc.).&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Jan Tošovský</dc:creator>
    <dc:date>2019-05-21T16:49:19Z</dc:date>
  </entry>
</feed>
