Code Monkey home page Code Monkey logo

Comments (13)

jengjeng avatar jengjeng commented on September 21, 2024 6

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.

truckingsim avatar truckingsim commented on September 21, 2024

Can you post the ajaxSelectPicker code you are using? So we can see your config.

from ajax-bootstrap-select.

marisoru avatar marisoru commented on September 21, 2024

The options:

test

and

$('#reportTemplateGroupFieldValues').selectpicker().ajaxSelectPicker(optionsGroups);

from ajax-bootstrap-select.

truckingsim avatar truckingsim commented on September 21, 2024

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.

diegoaam avatar diegoaam commented on September 21, 2024

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

showcase

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
showcase2

from ajax-bootstrap-select.

truckingsim avatar truckingsim commented on September 21, 2024

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.

KaitaniLabs avatar KaitaniLabs commented on September 21, 2024

+1, I also need this for my system. Thanks

from ajax-bootstrap-select.

truckingsim avatar truckingsim commented on September 21, 2024

@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.

markhalliwell avatar markhalliwell commented on September 21, 2024

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.

truckingsim avatar truckingsim commented on September 21, 2024

Thanks for giving it a quick once over. Just moved myself so fully understand. Good luck!

from ajax-bootstrap-select.

truckingsim avatar truckingsim commented on September 21, 2024

Adding this 2.0.0 I really want to get this fixed.

from ajax-bootstrap-select.

callumstrubi avatar callumstrubi commented on September 21, 2024

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.

markhalliwell avatar markhalliwell commented on September 21, 2024

I believe this will be fixed by #164

from ajax-bootstrap-select.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.