1

Currently there is a bug in Firefox that doesn't let you to copy stuff from disabled textarea (in chrome it works fine) and I've been thinking how can I replace my code so that it works ok in firefox as well. i'm using GSP files but can use normal html tags within them as well.

Here is my code snippet:

<g:textArea rows="5" cols="1" name="description" value="${forecast?.description}" class="description-t-area" disabled="${!canEdit}"/>

And here is image how it looks on the web: enter image description here

doublemc
  • 3,021
  • 5
  • 34
  • 61

2 Answers2

0

The issue is that you can not set disabled to true or false, the existence of the attribute means true, eg:

disabled="false" == true
disabled="true"  == true
disabled         == true

You have two options, use a plain text-area and conditionally print disabled or nothing html tag or set disabled via javascript.

More info here Correct value for disabled attribute

Edit: Just tried this is Grails 3.2.8 and it does actually work correctly now (been a while since I've looked, sorry!)

<g:textArea name="foo" disabled="${false}"/>

results in

<textarea name="foo" id="foo" ></textarea>

and

<g:textArea name="foo" disabled="${true}"/>

results in

<textarea name="foo" id="foo" disabled="true" ></textarea>
Community
  • 1
  • 1
erichelgeson
  • 2,310
  • 1
  • 16
  • 24
0

You could use pre tag e.g.

<pre id="description" contenteditable="${!canEdit}">${forecast?.description}</pre>
Mike W
  • 3,853
  • 2
  • 11
  • 18