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

Using ajax with preselected option #45

Closed
link-point opened this issue Apr 13, 2015 · 5 comments
Closed

Using ajax with preselected option #45

link-point opened this issue Apr 13, 2015 · 5 comments

Comments

@link-point
Copy link

Hi,

I'm trying to use the ajax select with an update form, like the example in this fiddle: http://jsfiddle.net/okbnumdc/10/. Basically, before the first ajax is sent, I already want to have one option selected.

What I did is I took a working example (http://jsfiddle.net/okbnumdc/9/) and just added an existing option to the select list with an attribute "selected". It is shown as selected at first, but when I try to choose a different option, the select message turns to "Select and Begin Typing". Is there a bug with preselecting an option?

Best regards,
Gregor

@truckingsim
Copy link
Owner

This issue: #41 applies to single selects as well. I still haven't figured out why the heck its not working on pre selected options. If you figure out anything when working through this please let me know. Right now I could take any information.

Sorry its not working for you.

@sharmilanAmpi
Copy link

Hi guys,
I had also the same issue that i have some options before load ajax bootstrap select to a element.
But i resolve by using

   $('your element ID').trigger('change');

after you add the ajax bootstrap select.

in your example http://jsfiddle.net/okbnumdc/10/ add this line in the end of js.
$('select').trigger('change');

It works fine for me but couldn't keep more then one options. If any one can resolve it let me know please.

@truckingsim
Copy link
Owner

@Sharmi89 it couldn't keep more than one option in the example at least because it wasn't a multi select.

See: https://jsfiddle.net/okbnumdc/14/ for an example with multi select working with your patch for at least temporarily resolving this.

@link-point
Copy link
Author

Thanks @Sharmi89! Your solution works like a treat.

At least in the fiddle, I still have to figure out why it fails in my project, but that is another story :)

@truckingsim
Copy link
Owner

#76 should fix this. If its still an issue open a new issue.

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

No branches or pull requests

3 participants