Settings' Options functions (_js). #1172
-
Hello @vladmandic . We're trying to add refresh without reset to dominik's autocomplete, and I can't quite tell whether this is possible: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
i haven't tried, but this should work... typical use of optioninfo: options_templates.update(options_section(('system-paths', "System Paths"), {
"temp_dir": OptionInfo("", "Directory for temporary images; leave empty for default"),
} and now with hijaack my_option = OptionInfo("", "Directory for temporary images; leave empty for default")
my_option.component.change(fn=None, _js="my_js_function", inputs=[], outputs=[])
options_templates.update(options_section(('system-paths', "System Paths"), {
"temp_dir": my_option,
} |
Beta Was this translation helpful? Give feedback.
-
ok, now wer're talking about silly workarounds - it would be easy to create something that would work cleanly for you, but then you wouldn't be compatible with other forks. for example: def refresh_data():
# fetch filenames from folders and just put everything together as a json and dump it to str
return text
btn_refresh_data = gr.Button(...)
text_data = gr.Text(..., visible=False)
btn_refresh_data.click(fn=refresh_data, _js="request_data", inputs=[], outputs=[text_data])
btn_send_data = gr.Button(..., visible=False)
btn_send_data.click(fn=None, _js="send_data", inputs=[text_data], outputs=[]) and in js: const request_data = () => setTimeout(() => gradioApp().getElementById('btn_send_data").click(), 250));
const send_data = (data) => { ...whatever you want here... }; actual data is is passed via hidden gradio textbox and you have separate refresh and send buttons so send to js event can happen after refresh. |
Beta Was this translation helpful? Give feedback.
i haven't tried, but this should work...
typical use of optioninfo:
and now with hijaack