Skip to content

When attempting to disable selectpicker, the menu itself still opens. #2881

@bouttellharry

Description

@bouttellharry

Hi.

So I've been using Bootstrap selectpicker for a website that I'm making at work.
When the user is under certain roles. I want these selectpickers to be disabled. Not allowing them to see any other option.
Now, despite being unable to select another option - the menu can still be opened allowing the user to still see the other users.

It works when using: $('#selectpickerName').attr('disabled', true).selectpicker('refresh') HOWEVER I then run into the bug with duplicating options, where it'll say "Selected optionSelected option".

Any suggestions?

Activity

DoctorWho406

DoctorWho406 commented on Jun 6, 2025

@DoctorWho406

I am facing the same issue
For the disabled state I can advise you two things

  1. Be careful to set the disabled attribute to the original select and not to the SelectPicker
  2. I know it doesn't make much sense, but separate the lines of your code like this:
$('#selectpickerName').attr('disabled', true);
$('#selectpickerName').selectpicker('refresh');

This helped me to make the selectpicker actually become disabled

For the repeated values ​​issue I don't know what to tell you, I'm stuck there too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @DoctorWho406@bouttellharry

        Issue actions

          When attempting to disable selectpicker, the menu itself still opens. · Issue #2881 · snapappointments/bootstrap-select