-
Notifications
You must be signed in to change notification settings - Fork 31
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
Default to blank #11
Comments
Hi! |
Thanks mate. I've just tried setting the underlying select like in that fiddle, but it doesn't affect the Simple Combobox. I realise a new parameter might be some time away, so in the meantime is there any chance you do a fiddle showing how to set a Simple Combobox to blank like that? I've found that .scombobox('val',''); works just after creating the combo, but once the user has selected an option it no longer works. |
http://jsfiddle.net/ivkremer/ZM3dY/ BTW I found another very stupid bug. After typing a valid value in combobox and losing its focus by clicking the body, the combo's value doesn't change. |
@RyanPaddyFronde I think I should close it, am I right? |
Thanks, using .scombobox('val', null) works for me to clear the initial value of the combo on page load. The other half of the problem is that I'm using the combo to select a value to be input into another control, and then I want the clear the combo. I've tried doing this in the onchange() of the tag, but it doesn't work. I imagine this is an HTML/browser restriction to stop recursion of the onChange, but it would be good to find a way around it. |
@RyanPaddyFronde If you can show it with a fiddle that would be very appreciated. |
I'm having issues with this as well. I don't want it to default to any values until typed in. I have a blank option in my list, but it's lost when converted to a combobox. None of the fiddles above work, all are 404 (except the last one). |
@cmeza can you provide a snippet about a blank option? |
It begs the question why would you have to programatically add an empty option if one already exists? It looses the existing one when converting to a scombobox. That doesn't produce an empty option when it's instantiated? |
@cmeza do you mean |
doesn't work, but
does |
Sorry, been busy last few days. <select>
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
</select> Yes, @ivkremer that's basically what I mean. That 1st option doesn't even make it to rendered scombobox version. It just seems like it's time to add a feature to NOT have the list start with the first option or allow blanks defined in the data to be displayed. Either an option to show the combobox empty or allow blanks. So it more functions like an input/autocomplete, but I need the value of a selected option! That's why I liked scombobox vs autocomplete. |
@cmeza @RyanPaddyFronde now there is an $('#my-combobox').scombobox({
data: [{
value: '001', text: 'The first'
}, {
// the combo will have '002' as its value and display 'The second'
value: '002', text: 'The second', selected: true
}, {
value: '003', text: 'The third'
}]//, // uncomment this and the combo will be empty anyway:
//empty: true
}); I'm going to close this issue if everything is ok now, thanks for reporting. |
I've tried the new empty option and it answers my original request, thanks. Using .scombobox('val', null) works to clear the combo after it's been created. Setting val to null doesn't work in the list's onChange event (i.e. to clear it after it is used to select an item), but this is a standard HTML select limitation that can be worked around with a timeout, like this: setTimeout(function(){combo.scombobox('val', null);}, 1); So, all sorted for me. |
I'll get the latest & let you know. |
@RyanPaddyFronde But now, as I understand there is no need to execute |
There is a need, due to my use case:
|
This is a problem for me too. My select has options:
And I initialize the scombobox with:
After initialization the blank option gets removed from the original select. No option is marked as selected and the scombobox input has no value. But If I post the form the value of the first option gets sent to the server. Which is not what I would expect to happen as user has not selected any values. |
Found the reason why the empty option is removed. There is a method Update: |
The combobox defaults to the first item in the list. Is it possible to make it default to a blank value instead?
The text was updated successfully, but these errors were encountered: