The dropdown feature fails to function properly when contained within a Bootstrap Popover

Utilizing jQuery v1.12.4, Bootstrap v3.3.7 and Bootstrap-Select v1.10.0.

In a popover, I have 2 components. When the popover is opened, I am able to interact with the dropdowns but the selection does not change when clicking an option.

You can view the example on jsfiddle.

CSS

.flex { display: flex; }

HTML

<div>
  <a role="button" class="btn btn-default" data-poc="#beds" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Bedrooms <span class="caret"></span></a>
  <div id="beds" class="hide">
    <div class="flex">
      <select name="minBeds" id="minBeds" class="selectpicker">
        <option>Min Beds</option>
        <option value="1">1 Bed</option>
        <option value="2">2 Bed</option>
        <option value="3">3 Bed</option>
        <option value="4">4 Bed</option>
        <option value="5">5 Bed</option>
      </select>
      <select name="maxBeds" id="maxBeds" class="selectpicker">
        <option>Max Beds</option>
        <option value="1">1 Bed</option>
        <option value="2">2 Bed</option>
        <option value="3">3 Bed</option>
        <option value="4">4 Bed</option>
        <option value="5">5 Bed</option>
      </select>
    </div>
  </div>
</div>

JS

$(document).ready(function() {
  $('.po').popover({
    animation: false,
    placement: 'bottom',
    html: true,
    content: function() {
      var poc = $(this).attr('data-poc');
      return $(poc).html();
    }
  });
});

Answer №1

Encountering an issue with the functionality of popover and bootstrap-select, it appears to be a bug. One potential solution is:

$('.po').popover({
    content: $('#beds').html(),
    placement: 'bottom',
    html: true
}).on('shown.bs.popover', function() {
    $('.selectpicker2').selectpicker();
});

To see the outcome, check out the demonstration on JSFiddle. Further discussion on this issue can be found here.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Getting node.js code to function in a web browser

As a newcomer to Node.js, I decided to create a chat application as a hands-on learning experience. My choice of library was ws. During my experiment, I discovered that Node.js code doesn't work directly in browsers, especially when it comes to requi ...

Extract the initial 7 keys from an object and transfer them to a separate object

Is there a way in JavaScript to create a new object that contains only the first 7 keys of another object? This is the object structure from which I want to extract the data. {"data":[{"id":2338785,"team1":{"id":10531,"name":"Just For Fun"},"team2":{"id": ...

Tips for specifying headings for a particular div ID

I'm attempting to customize the font-family of the headings within my header section differently from the headings located elsewhere on the webpage. Unfortunately, I am encountering difficulties in ensuring that this style change only affects the spec ...

Show a confirmation dialog box using bootbox that includes a link when the user selects OK

I am currently experimenting with integrating bootbox.js into a test page. However, I am facing an issue where the href tag in the hyperlink triggers regardless of whether the user selects the Cancel or OK button on the bootbox. Is there a way to include ...

Using Regex instead of the method resulted in logging an unexpected output, displaying the matched text as $& and the

I have a regular expression that I'm using with the .replace method to extract paragraphs from a string and add them to an array. I've been struggling with my getValues function; when I logged Match and Group1 to the console, I got unexpected re ...

Using jQuery to toggle the visibility of a group of radio buttons causes the div to quickly appear and disappear

My code is working perfectly as it shows up when needed and disappears when necessary. The concept behind this form is that the user can check a box, view more required form data related to the checked item, make those fields required, and then uncheck the ...

Create a collection of functions within an array that each return promises

I have created 4 different functions that return promises. By running the "hello" function and passing each subsequent function into the next .then, you can generate a single long string output. var hello = function(str){ return Promise.resolve(str + "h ...

Navigate to various parts of the page easily with a stationary navbar

After successfully implementing buttons to jump to different sections of my page using IDs like this: <button id="niftyBtn"><a href="#nifty">Things</a></button></br> <div id="nifty">Blah</div> I'm facing an ...

Resolve the Prototype_Pollution vulnerability detected by Checkmarx

When executing the code line window.location.search.substring(1) with the word 'substring(1)', an error related to Prototype_Pollution occurs. This error is caused by assigning external properties without proper validation, which can lead to obje ...

Utilizing React: passing a Component as a prop and enhancing it with additional properties

My question involves a versatile component setup like the one below const Img = ({ component }) => { const image_ref = useRef() return ( <> {component ref={image_ref} } </> ) } I am exploring ways to use this compo ...

refreshing a javascript function without the need for reloading

Attempting to create an embedded web server using the Nano WiReach SMT. Here is the code that has been written so far: <HTML> <HEAD> <SCRIPT LANGUAGE=JavaScript> function swapImage() { var val1 ...

What is the best method for iterating through the AJAX response?

I am currently exploring AJAX coding techniques and have recently started using jQuery. My goal is to retrieve subcategories from a MongoDB database and dynamically populate them in separate option tags within a select tag once the parent select tag is cli ...

What could be causing CSS_SELECTOR to sometimes fail to locate the HTML tag?

I have developed a script that automates clicking on different Instagram prompts using CSS_SELECTOR to identify and interact with these buttons. However, I am facing an issue where the script only works intermittently. wait.until(ec.element_to_be_clickable ...

Multiple occurrences of jQuery click event triggered on the parent element

https://jsfiddle.net/50Lw423g/2/ function runGameLogic() { console.log("GAME LOGIC"); alert("Your Turn!"); var that = this; $(".game-screen").on("click", ".tic", function() { console.log("EVENT ATTACHED"); var movesDisplay = ...

Encountering issues with webpack module federation and single-spa-vue integration, specifically with Vue version 2.16.12

I'm currently facing an issue while developing a microfrontend using single-spa-vue and Vue 2.6.12. To set up my project, I am utilizing the webpack module federation plugin. Below is the entry point for my application: src/app.ts import singleSpaV ...

Guide to implementing optional localization strings in React-Router paths

Incorporating react-router, I aim to implement internationalization for links following this format: domain.com/langISO/countryISO2/page Here are some examples of valid routes: domain.com/ -> Home Page domain.com/en/us -> Home Page domain.com/fr/f ...

Utilizing jQuery and Bootstrap imports within a JavaScript file

Having difficulty importing libraries into my JS file. While the code functions when placed in a script tag in my HTML file (where I included jQuery and Bootstrap), it fails to work when placed in my JS file. My attempt to import the Bootstrap library thr ...

Accessing a document using protractor

It seems like every protractor example I come across online uses browser.get with a web URI. browser.get('http://localhost:8000'); I want to use Selenium to navigate to a local file:// path without needing a web server running. Just a simple HT ...

Configuration of injected services in IONIC 2

I am curious about how the services from injected work in IONIC 2. Specifically, my question is regarding the number of instances that exist when one service is used in two or more controllers. Previously, I asked a colleague who mentioned that IONIC 2 op ...

Camera Capacitor designed to eliminate popup notifications

I am utilizing Angular along with the camera plugin in Capacitor to locally save images on both desktop and tablets. I aim to utilize the CameraSource to directly access the camera or open the gallery for files without displaying a prompt. This is how my ...