Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
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



Arun Patidar

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



Arun Patidar

Avatar

Level 3

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