Reputation:
I am working in react JS. I want to make an input field editable on double click. is it possible in react or should I use a third party library?
Upvotes: 2
Views: 359
Reputation: 522
If I understood your question correctly, you could simply add an onDoubleClick
event listener to your input
and use it to toggle readOnly
:
const [readOnly, setReadOnly] = useState(true);
return (
<input readOnly={readOnly} onDoubleClick={() => setReadOnly(false)}/>
)
Upvotes: 1
Reputation: 129
Yes, it is possible in three ways. You can use Bootstrap 3, Jquery, or JQuery UI as well. Bootstrap is the best option among all these because of having excess material over the internet. You can use "X-Editable". This will provide you to make that specific field editable of will open a pop-over on the input field. Link: https://vitalets.github.io/x-editable/
Upvotes: 0