-
Notifications
You must be signed in to change notification settings - Fork 323
How Set a value via jQuery ? #75
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
Comments
Huh, well I thought that if you had the select element you should be able to set it's value and trigger change and that would make the combobox change, but that does not appear to be working anymore. I'll mark this as a bug because I want that behavior. |
ok Daniel, thank you very much for this plugin, I am using it in my project. |
I am able to select an option by text (i.e. the text is the variable consFrame) programmatically with this approach:
where custom_menu_obj is the combobox menu object (I had to add the id attr to your js). However there is a catch. This only works if you have previously opened the target combobox, since the 'ul' and all its children do not load into the DOM until they have been clicked on. |
I need this also, I can set the value and retrieve it with Any news on this bug? |
I am still waiting on an update for this as well. I have tried to solve it myself, but have been unsuccessful. One workaround that I have found is to call the 'toggle' twice on document/DOM ready - which forces the combobox to load into the DOM, then you can use the script I included above. Not elegant, but it works! Well, almost works, the combobox has some strange behaviour (two clicks on the remove to completely clear the box! sigh) |
This is not a use case I have at the moment, so one of you may have to fix it if you want it soon. My first instinct is that I'd do it is to listen for the change event on the select box and update the text input with the new value. I think the reason that didn't happen was because I think we trigger change on the select when you choose one. That would be circular. What I'd suggest pursuing is to add a method that you could call to update that could do all the necessary things. $('element').combobox('update', value) or something like that. |
I have tried that approach (as best I could), however the issue is that the < ul > and its children (i.e. < li >') doesn't get loaded into the DOM until the combobox is manually selected by the user. Because of this, I don't see a way to add the class="active" to a desired < li > in the dropdown at the document ready point before the user has a chance to interact with the page. Am I missing something? |
I do that for select boxes that have a value selected already. You should look in that code and see what happens there. You shouldn't have to do that manually. |
This is currently how I would do it:
|
Refreshing combobox data works for me too. |
Refreshing works but not for options that have an empty value. <select id="example">
<option value="">No Value</option>
<option value="1">A Value</option>
</select> $('#example').combobox();
// Works
$('#example').val('1');
$('#example').data('combobox').refresh();
// Doesn't work
$('#example').val('');
$('#example').data('combobox').refresh();
// Doesn't work
$('#example').val(null);
$('#example').data('combobox').refresh();
// Doesn't work
$('#example').val(undefined);
$('#example').data('combobox').refresh(); |
$("myComboBoxSelector").data('combobox').refresh() |
I need select a val from options via jQuery
The text was updated successfully, but these errors were encountered: