-
Notifications
You must be signed in to change notification settings - Fork 325
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
Update the README #261
Comments
It's not straight-forward, but looking at the tests I came up with this: https://jsfiddle.net/mwcjLs8p/1/ <select id="test-combobox" class="combobox">
<option></option>
<option value="PA">Pennsylvania</option>
<option value="CT">Connecticut</option>
<option value="NY">New York</option>
<option value="MD">Maryland</option>
<option value="VA">Virginia</option>
</select>
<button type="button" id="update" class="btn btn-primary">
Set to Maryland
</button> var $combobox = $('#test-combobox').combobox();
$('#update').on('click', function(e) {
e.preventDefault();
$combobox.data('combobox').$element.val('MD');
$combobox.data('combobox').lookup();
}) Whether or not that's the easiest way, I don't know. I'll have to dig into the source a bit more. |
Thank you very much for your reply. var $combobox = $('#test-combobox').combobox();
$('#update').on('click', function(e) {
e.preventDefault();
$combobox.data('combobox').$element.val('MD');
$combobox.data('combobox').lookup();
$combobox.data('combobox').select();
}) |
I have found a solution that works for me. But it tooks me hours and the result is so simple.. <select id="test-trigger-combobox" class="combobox">
<option></option>
<option value="1">User A</option>
<option value="2">User B</option>
<option value="3">User C</option>
<option value="4">User D</option>
</select>
<select id="test-target-combobox" class="combobox">
<option></option>
<option value="1">Company D</option>
<option value="2">Company C</option>
<option value="3">Company B</option>
<option value="4">Company A</option>
</select> $('.combobox').combobox();
var $target_combobox = $('#test-target-combobox').combobox();
var $association_ids = [0, 4, 3, 2, 1]; // user 1 belongs to company 4, user 2 to company 3...
$('#test-trigger-combobox').on('change', function(e) {
//e.preventDefault();
var trigger_id = $(this).val();
var target_id = $association_ids[trigger_id];
$target_combobox.val(target_id);
$target_combobox.data('combobox').refresh();
}) I found the needed hint here in Bug #75 at the bottom. |
I need to use lot of dynamic access, when the page is loaded already.
F.ex. Changing a combobox value by the user will trigger to reinitialize the content of an other combobox, based on the selected value in the first. Think of it like a category selection. Main category select -> subcategory select..
Further. What i still didn't found is how i can change the selected value with JQuery.
The case is when i select an 'user' in the combobox, other comboboxes like 'address' and 'company' should auto select the associated values.
Im sure the selected option is available (after the combobox is first initialized), but i didn't found how.
So maybe you could update the README files with parameters/values for the options or an example usage for each option. That would help to easy get started.
The text was updated successfully, but these errors were encountered: