Hello Dash Community!
My question: How to set focus on element (for examle input line) by means of Dash? Is it possible?
Hello Dash Community!
My question: How to set focus on element (for examle input line) by means of Dash? Is it possible?
You could put a JavaScript file in your /assets
folder, possibly with a Clientside callback (see the relevant section at the bottom of the page). You could then use the HTMLElement.focus()
function from the Web API. For example, given a component with the id
text_input_id
, you would call document.getElementById("text_input_id").focus();
Thank you! Clienside callback is very usefull! But I do not understand how can I handle events in this case? Can I handle events as well as in usual javacript or not?
For instance, the code
āāā
JS
window.dash_clientside = Object.assign({}, window.dash_clientside, {
test_clear: function(ch) {
e=window.event;
if(e.type==āclickā && e.target.id==ātest_clearallā){
alert(āŠŠ½Š¾ŠæŠŗŠ° Š½Š°Š¶Š°ŃŠ°ā);
return āā;
}
}
});
āāā
āāā
PY
app.clientside_callback(
ClientsideFunction(
namespace=āclientsideā,
function_name=ātest_clearā
),
Output(ātest_inputā, āvalueā),
[Input(ātest_clearallā, āchildrenā)]
)
āāā
does not work.
Thank you very much!
I have done everything what I wanted.
@oansh, could you please post your solution here? I need to achieve the same (and Iām not very familiar with JS).
Thanks a lot!
Just in case anyone has run into this problem. Think Iāve solved it with a clientside callback with embedded javascript straight into the dash app. No separate .js file needed.