Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Set Select drop down value on dialog ready

Avatar

Avatar
Level 1
troubleshooter3
Level 1

Likes

0 likes

Total Posts

14 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
troubleshooter3
Level 1

Likes

0 likes

Total Posts

14 posts

Correct Reply

0 solutions
View profile
troubleshooter3
Level 1

09-02-2021

I have a drop down called subject, I have 3 options in that drop down. How can I preselect the the option based on template or URL or any other thing so that author does not have to choose that option.

View Entire Topic

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

591 likes

Total Posts

572 posts

Correct Reply

219 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

591 likes

Total Posts

572 posts

Correct Reply

219 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

09-02-2021

@troubleshooter3,

For your requirement, with logic for pre-selecting the Granite UI dropdown, you can create a client-library with JS logic; with the category as cq.authoring.editor.hook. This when the client library is invoked, the custom JS logic will detect the template of the current page and will pre-select the drop-down options accordingly, but the logic will run only when the current drop-down value has NOT been set.

Making sure your client library have correctly set categories and dependencies:

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="cq:ClientLibraryFolder"
    allowProxy="{Boolean}true"
    categories="[cq.authoring.editor.hook]"
    dependencies="[cq.authoring.editor.core]"/>