Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectbox #9

Open
NamPNQ opened this issue Aug 3, 2015 · 4 comments
Open

Selectbox #9

NamPNQ opened this issue Aug 3, 2015 · 4 comments
Labels

Comments

@NamPNQ
Copy link
Contributor

NamPNQ commented Aug 3, 2015

Why we not use selectbox instead of input field

@mrmarkfrench
Copy link
Owner

It's implemented the way it is because the library it's based off of did it this way. Much of the implementation is a straight translation of that code. There's no specific reason not to use a selctbox.

If you have a better implementation, send a pull request. I'd be happy to look at it.

@BrettGregson
Copy link

Fairly simple solution to make it act like a select:

Add a readonly property to the input that you are applying the library to (readonly="readonly")

Add a function to set the $('.country-select .selected-flag') element to the width of the it's parent element (this might change depending on your HTML):

function setupFlags(){
    var targetWidth = $(".country-select").width();
    $('.country-select .selected-flag').css("width", targetWidth);
}

Call the setupFlags() function on document ready and on window.onresize if applicable

@mrmarkfrench
Copy link
Owner

Thanks, @invalidusernam3, that sounds like a pretty elegant way of making it work like @NamPNQ wants it to. I like that it solves the problem of letting others allow their users to type directly into the field to find what they're looking for, but also makes it simple to change the behavior for a different use case if desired.

Would you like to submit a pull request to make your suggested solution an option built into the library? You could trigger a call to a function like the setUpFlags() you describe there (maybe with a more descriptive name), based on a field in the options object passed to the constructor.

@BrettGregson
Copy link

No problem @mrmarkfrench, I'll clean it up a bit and submit a pull request tomorrow after work. I might also do the setting of the country name (from the select) on the input after the user has selected a country (as mentioned in one of the issues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants