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

Support of linked label #316

Open GMartigny opened 9 years ago

GMartigny commented 9 years ago

Hi,

I start using SelectBoxIt and find it great. But I can't get

I'll hack it with a little jquery event handler, but that really should go on the main code.

Thanks for your hard work.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/8454671-support-of-linked-label?utm_campaign=plugin&utm_content=tracker%2F23157&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F23157&utm_medium=issues&utm_source=github).
GMartigny commented 9 years ago

For thoses with the same problem, here my solution (I use delegated event so it's a bit more complex than it should).

Add this on the "focus.selectBoxIt" event (l.1189).

var z=$.Event("focus");
z.target=d.selectBox[0];
$(document).trigger(z);

Then, Insert the focus function directly on the widget (l.849 ).

focus: function(a){
    var b=this,
        f=b.options["native"],
        g=b.isMobile;
    return !b.listItems.length ||
        b.dropdown.hasClass(b.theme.disabled)?b:
        (f || g || this.list.is(":visible") ||
            b.dropdown.trigger("focus",!0), b._callbackSupport(a), b);
},

Finaly, we need to link with corresponding label, add on the "_create" function (l.350).

$("label[for=" + d.element.attr("id") + "]").on("click", function(){d.focus();});