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

Request: open and close methods #1893

Closed
mafar opened this issue Jan 10, 2018 · 4 comments
Closed

Request: open and close methods #1893

mafar opened this issue Jan 10, 2018 · 4 comments
Milestone

Comments

@mafar
Copy link

mafar commented Jan 10, 2018

Objective:
Similar to .selectpicker('toggle') , options like close and open are required

  1. .selectpicker('open') open all pickers
  2. .selectpicker('close') close all pickers

Purpose:
sometimes it is required to close down all bootstrap-select pickers while .selectpicker('toggle')only switched between open and closed states.
These options will help in achieve either opening or closing one or more selectpickers

Solution:

  1. add 2 functions after toggle function in source code
  2. Working fiddle after source change http://jsfiddle.net/bababalcksheep/RUAS4/563/

Tests:

  1. tested with container option as well and works
  2. tested and fires all respective events as well

Sample:
added open: function (e) { and close: function (e) { after toggle in source

    toggle: function (e) {
      e = e || window.event;

      if (e) e.stopPropagation();

      this.$button.trigger('click');
    },

    open: function (e) {
      e = e || window.event;

      if (e) e.stopPropagation();

      if  (!this.$newElement.hasClass('open'))  this.$button.trigger('click');      
    },

    close: function (e) {
      e = e || window.event;

      if (e) e.stopPropagation();

      if  (this.$newElement.hasClass('open'))  this.$button.trigger('click');      
    },
@mafar mafar changed the title Request: bootstrap-select open and close options Request: open and close methods Jan 10, 2018
@TomKrakott
Copy link

+1

@scr4bble
Copy link

What is the status of this issue please?
Is there a way to close the select programmatically?
I only see method for toggle and that's not really what I need. Or is there a way to query whether select is opened so I could filter the opened ones and close them by toggle?

@caseyjhol caseyjhol added this to the v1.15.0 milestone May 7, 2020
@caseyjhol caseyjhol modified the milestones: v1.15.0, v1.14.0 May 7, 2020
@caseyjhol
Copy link
Member

This change will be a part of the v1.14.0 release. This issue will be updated after it's made available.

@caseyjhol
Copy link
Member

Released in v1.14.0-beta!

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

No branches or pull requests

4 participants