views:

431

answers:

2

Hello all,

I need to perform an action on double click of a text box, but the onDblClick event does not seem to register when the text box is not editable (i.e greyed out). Is there something I can do to solve this ?

Best, Rohan

+2  A: 

How about applying the onDblClick event to the parent div your text box is in?

e.g.

<div ondblclick="someAction()"><input type="text" readonly="true" /></div>
kchau
That is great idea. Thanks!
rohangter
+1  A: 

Apparently ,

The legacy code was using the 'disabled' property of the element to toggle editability of the text box. So that also disables events on the text box.

textElement.disabled = true;

To fix this,

I used the 'readOnly' property of the element for the editability toggling needs and now it registers events.

textElement.readOnly = true;

Thanks for reading!

Rohan.

rohangter
That makes sense. Glad you got it working.
kchau