Comments (13)
You need to insert <option selected>
tag before initializing select picker and prevent cache bug by using this code
// Use after init select picker
$('#select-picker').trigger('change').data('AjaxBootstrapSelect').list.cache = {}
You can try from this fiddle https://jsfiddle.net/kinkongjeng/2o7j08kb/
from ajax-bootstrap-select.
Can you post the ajaxSelectPicker code you are using? So we can see your config.
from ajax-bootstrap-select.
The options:
and
$('#reportTemplateGroupFieldValues').selectpicker().ajaxSelectPicker(optionsGroups);
from ajax-bootstrap-select.
So we have an option called preserveSelected
which will keep previously selected options between ajax requests. Try adding that to your options hash.
var optionsGroups = {
ajax: { ... },
log: 3,
preprocessData: function(){ ... },
preserveSelected: true
};
from ajax-bootstrap-select.
Hello, and thanks for the quick answers you give, I have the same problem, I tried with the preserveSelected that you said, and it does not work, I think the problem is that the style of ajaxSelectPicker are not applied, and when I type something it applies the styles and for sure deletes the selected values
If you see the left image the styles are not applied, it should have a 'Current Selected' div and all that stuff
In the next image I clicked on 'Brasil' and now 'Colombia' goes to Currently Selected and then I can type without any problem
from ajax-bootstrap-select.
Ahh that second image helps. Ok yeah this is a bug. Basically we aren't checking for currently selected on initialization only on update/keydown. It will probably be this weekend before I have time to work on this though.
from ajax-bootstrap-select.
+1, I also need this for my system. Thanks
from ajax-bootstrap-select.
@diegoaam @MarkCarver I've spent 5 hours on this so far over multiple days and haven't been able to find out why it can't keep initial selected options yet.
@MarkCarver If you can find time, I'm pushing up a bugfix branch which has what I've done so far, maybe you'll see something. The commit df4b2b5 has the change I made that will save one of the options but not both. I also added a 4th select to the example page for testing this.
from ajax-bootstrap-select.
I'll have to look at this in more depth later. This month is going to be chaotic for me (family/moving).
from ajax-bootstrap-select.
Thanks for giving it a quick once over. Just moved myself so fully understand. Good luck!
from ajax-bootstrap-select.
Adding this 2.0.0 I really want to get this fixed.
from ajax-bootstrap-select.
Can confirm that the fix from @jengjeng works and also fixes a secondary bug of de-selecting pre-selected options that must be incorrectly initialised.
I'd consider this bug critical and without the workaround we'd have had to implement an alternative library entirely.
from ajax-bootstrap-select.
I believe this will be fixed by #164
from ajax-bootstrap-select.
Related Issues (20)
- ajax-bootstrap-select breaks required field HOT 1
- with-ajax makes changed.bs.select event to be called on search, not on change HOT 10
- New release - update of dist files
- How to hide locale.statusInitialized field?
- No results event HOT 1
- Trigger options when initialization HOT 1
- Post not not reach the server
- Attempting to destroy selectpicker and reinitialize ajaxselect creates standard select HOT 2
- Cancel the previous request if another one has been sent. HOT 1
- multiple + preserveSelected + default <options> groups unselected options into 'Currently Selected' HOT 2
- Selecting an empty option doesn't seem possible
- Add sort for selectpicker
- not working correctly in mobile
- Search Filtering
- Add support for HTML attributs "data-xxx" on custom content
- Return in HTML (Retorno em HTML)
- In Bootstrap 5.2.3 Ajax-Bootstrap-Select doesn't work HOT 8
- Select text content as you type (Selecionar o conteúdo do texto enquanto digita) HOT 1
- Make the function dynamic (Deixar a função dinâmica) HOT 1
- selectpicker show method not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ajax-bootstrap-select.