Hi,
I’m trying to make a functionality to my dcc textarea.
The functionality should be as follows:
- If the edit button is not pressed, the textarea is locked for input
- When the edit button is pressed, the textarea becomes editable and the save button appears and the edit button gets hidden.
3 . After the user have input their comments, they press the save button and the input is saved. - We are back to 1, where the edit button is visible again and the save button is hidden.
The area of my code where I need help is the following:
html.Div([
dcc.Textarea(
id='textarea_comments_growth',
value='',
placeholder='Write comments here',
persistence=True, persistence_type='local',
readOnly=True,
style={'width': '100%', 'height': 200,'display': 'block'}),
html.Button('Save', id='save_button_growth', n_clicks=0, hidden = True),
html.Button('Edit', id='edit_button_growth', n_clicks=0),
html.Div(id='comments_growth', style={'whiteSpace': 'pre-line'})
]),
])
@app.callback(
Output('comments_growth', 'children'),
Input('save_button_growth', 'n_clicks'),
Input('edit_button_growth', 'n_clicks'),
State('textarea_comments_growth', 'value')
)
def update_output(save, edit, comment):
if edit > 0:
#readability = {"readOnly":"True"}
comment.readOnly = False
return comment
# if save > 0:
# return comment
Is there anyone that can help me with this?
Thanks in advance!