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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Generating random number for a dialog field

Avatar

Level 3

Hi,

I am trying to have a hidden field in my dialog so that whenever i open the dialog in edit mode, a random number gets assigned to that hidden field.

Does anyone has any idea about generating random number for a dialog field?

Thanks,

Priya

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

You can write javascript [clientLibs (cq.authoring.dialog)] which will be called when dialog loads and assign value to hidden field.

JavaScript random() Method

You can use JQuery to handle events. For example, the following code represents the event handler that is invoked when the Touch UI dialog is opened:

$document.on("dialog-ready", function() {

        $(window).adaptTo("foundation-ui").alert("Open", "Dialog now open, event [dialog-ready]");

});

Thanks

Arun

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi,

You can write javascript [clientLibs (cq.authoring.dialog)] which will be called when dialog loads and assign value to hidden field.

JavaScript random() Method

You can use JQuery to handle events. For example, the following code represents the event handler that is invoked when the Touch UI dialog is opened:

$document.on("dialog-ready", function() {

        $(window).adaptTo("foundation-ui").alert("Open", "Dialog now open, event [dialog-ready]");

});

Thanks

Arun

Avatar

Level 3

Thanks for your quick response. I'll try generating it using javascript.