on focus, open list AND on change, move to next input?

790 views
Skip to first unread message

DFreeburn

unread,
Apr 7, 2013, 8:34:15 PM4/7/13
to sel...@googlegroups.com
Is there a 'focus' event for Select2 elements? I'm trying to set my select2's to open when focused, either by tab or otherwise. However, I'm also trying to add the functionality so when a selection is chosen, by keyboard or mouse, the focus moves automatically to the next input on the page.

Can anyone offer any advice on this? I've been having trouble with the .select2-focusser element that is dynamically created - it seems to steal focus back even when I use on('change') to set focus to the next element.

Thank you for your help!

bla...@sumologic.com

unread,
Apr 9, 2013, 12:43:36 PM4/9/13
to sel...@googlegroups.com, dun...@youthunlimitedkaw.com
I'm also having trouble with this behavior, Igor do you have any help?

I've tried hooking the close event and in the callback executing something like:

$('.select2-container').removeClass('select2-container-active')

But it has no effect, as the focusser runs after this event.

Thanks,
Bill

bla...@sumologic.com

unread,
Apr 24, 2013, 1:20:48 PM4/24/13
to sel...@googlegroups.com, dun...@youthunlimitedkaw.com
On Sunday, April 7, 2013 5:34:15 PM UTC-7, DFreeburn wrote:

Did you ever find a fix for this? I'm still stuck. I put this line in the change callback of my select2 element, which I can see getting hit by stepping through in the debugger but the focus call has no effect:

idSelector.on('change', function(event) {
$('#input-column').focus();
}
});

Thanks,
Bill

Message has been deleted

y.1j...@yahoo.com

unread,
Oct 5, 2015, 8:50:39 AM10/5/15
to select2, dun...@youthunlimitedkaw.com, bla...@sumologic.com
You guys found a solution for your problem?
I'm havving the same problem, damn it!

y.1j...@yahoo.com

unread,
Oct 6, 2015, 8:49:52 AM10/6/15
to select2, dun...@youthunlimitedkaw.com
Actually to open your comboBox select2 you have to just do:
$("#yourElement").select2('open');

Caio Cavalcanti

unread,
Oct 14, 2015, 2:40:14 PM10/14/15
to select2, dun...@youthunlimitedkaw.com
I got some of it working.

I was able to work on focus, but it didn't work on IE (which was a requisite u.u)

This is what I found and worked (Chrome, FF):

$("#my_id").select2();
$("#my_id").next(".select2").find(".select2-selection").focus(function() {
    $("#my_id").select2("open");
});

Now I need to find a way for this to work in IE.

Did anyone accomplish this?
Reply all
Reply to author
Forward
0 new messages