gfranko / jquery.selectBoxIt.js

A jQuery Select Box Plugin for Mobile, Tablet, and Desktop
http://www.selectboxit.com
MIT License
852 stars 301 forks source link

How to unfocus the dropdown after the change ? #279

Closed rprsnt closed 10 years ago

rprsnt commented 10 years ago

Hi, thanks for your amazing work ! In a classic dropdown, you can blur the dropdown after the choose (like that : http://jsfiddle.net/9TG8r/) But with selectboxit, the dropdown always becomes focused at the the end of the choose. Is there a way to unfocused it automatically ?

Thanks, Damien

gfranko commented 10 years ago

You should be able to use the special changed event to get this to work. Like this:

var selectBox = $("select").selectBoxIt();

// After the select box has been changed
selectBox.on('changed', function(ev, obj) {
  // obj.dropdown corresponds to the selectboxit dropdown
  obj.dropdown.blur();
});
rprsnt commented 10 years ago

Thanks, but it doesn't work, and i can't find the problem. I have exactly the same code as you :

$("select").selectBoxIt({
        hideCurrent: true,
        showEffect: "slideDown",
        showEffectSpeed: 100,
    });

    var selectBox = $("select").selectBoxIt();

    // After the select box has been changed
selectBox.on('changed', function(ev, obj) {
  // obj.dropdown corresponds to the selectboxit dropdown
  obj.dropdown.blur();
});

Thanks

rprsnt commented 10 years ago

Hi Greg, do you have any idea where my problem could come from? Many thanks !