Disabling a field in dialog

Avatar

Avatar
Applaud 25
Level 2
Shaheena_Sheikh
Level 2

Likes

2 likes

Total Posts

97 posts

Correct reply

1 solution
Top badges earned
Applaud 25
Applaud 5
Affirm 1
Validate 10
Validate 1
View profile

Avatar
Applaud 25
Level 2
Shaheena_Sheikh
Level 2

Likes

2 likes

Total Posts

97 posts

Correct reply

1 solution
Top badges earned
Applaud 25
Applaud 5
Affirm 1
Validate 10
Validate 1
View profile
Shaheena_Sheikh
Level 2

07-04-2021

I have the below code:

let fontField = $(".cq-dialog").find("#contentColor")[0];
fontField.value="#ffffff";
fontField.disabled=true;

 

the colorfield shows #ffffff and as disabled. But after closing the dialog, I don't see the color of the font as white (#ffffff). If I comment the line of code having disabled, the color starts reflecting. If i comment the third line of code, the value for the colorfield gets stored in the node but if I don't comment the third line then the value doesn't get stored at all. What am I missing?

(N.B this was working fine until yesterday, but today without making a change, it started breaking.)

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct reply

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

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

07-04-2021

@Shaheena_Sheikh 

disabled form fields will not be submitted.  You can try making it readonly.

Answers (1)

Answers (1)

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

07-04-2021

Hi @Shaheena_Sheikh 

 

Can you change "let" to "var" and try again?

 

The main difference between let and var is that scope of a variable defined with let is limited to the block in which it is declared while variable declared with var has the global scope. So we can say that var is rather a keyword which defines a variable globally regardless of block scope.

 

var fontField = $(".cq-dialog").find("#contentColor")[0];
fontField.value="#ffffff";
fontField.disabled=true;

 

Thanks!