Generating random number for a dialog field | Community
Skip to main content
Level 3
June 28, 2018
Solved

Generating random number for a dialog field

  • June 28, 2018
  • 3 replies
  • 2612 views

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.
Best answer by arunpatidar

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

3 replies

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
June 28, 2018

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
smacdonald2008
Level 10
June 28, 2018

Great response!

Level 3
June 29, 2018

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