jQWidgets Forums
jQuery UI Widgets › Forums › Lists › DropDownList › Restoring input focus after jqxDropDownList closes
Tagged: dropdown list, DropDownList
This topic contains 7 replies, has 3 voices, and was last updated by carpii 8 years, 4 months ago.
-
Author
-
I have a jqxDropDownList which is being used to select a font (animation is disabled so the list appears/disappears instantly).
After selecting a font, I want to restore input focus to a HTML input
But this doesn’t seem possible as the jqxDropDownList refocuses itself after it closes (ie, after my ‘close’ event handler has run)
Is there a way to achieve this? I would really like to avoid having to use a setInterval()
.on("select", "#fontpicker", function(e) { client.gui_update_font($(this)); }) .on("close", "#fontpicker", function(e) { client.gui_focus_last_chatinput(); })
Thanks
Hi carpii,
The DropDownList does not re-focus itself when it is closed. We focus it only when you click on it.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
Thanks for the reply. I have added some debugging to jqxDropDownList, but it does not behave as you say….
Whether you select an item via mouse or keyboard, it will issue a ‘close’ event, then an additional ‘change’ event, and finally in renderSelection it explicitly focuses the list div….
this.dropdownlistContent[0].innerHTML = j[0].innerHTML; if (this.focusable && this.isOpened()) { this.focus() }
Then end result is that there seems to be no way for me to handle the listbox being closed, and then restore the focus to a given control, since jqwDropDownList always steals back the focus afterwards
This hopefully demonstrates the issue I am having…
Hi carpii,
The widget does not steal the focus. The widget is focused while you click somewhere else.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
Would it be possible for you to check my demo jsfiddle please?
http://jsfiddle.net/te2qhzrb/9/
If you have any suggestions on how I can refocus the text input, after the DropDownList has been closed, that would be very helpful.
Perhaps it is not jqxDropDownList causing it, but even so, I am still left with a problem which I did not have when using a HTML selectHere is the native HTML select which works ok
http://jsfiddle.net/te2qhzrb/11/
I’d really appreciate any advice you can offer!
Thanks
Hi carpii,
Updated you sample: http://jsfiddle.net/jqwidgets/8e40wzc5/
Best Regards,
Peter Stoev
jQWidgets Team
http://www.jqwidgets.com/Thankyou Peter, this is working well
I was hoping to avoid using a timeout (not 100% sure why its necessary)
But as it appears to be the only way, I will live with it -
AuthorPosts
You must be logged in to reply to this topic.