Generating random number for a dialog field | Community
Skip to main content
Level 3
Jun 28, 2018 8:38 AM UTC
Solved

Generating random number for a dialog field

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Jun 28, 2018 8:51 AM UTC

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

3 replies

Level 3
Jun 29, 2018 5:13 AM UTC

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

Translate
smacdonald2008
Level 10
Jun 28, 2018 3:55 PM UTC

Great response!

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
Jun 28, 2018 8:51 AM UTC

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

Translate
Arun Patidar