Guide to triggering a popover from within another popover using jQuery

Currently, I have a situation where a popover is triggered by clicking on a button. The goal is to trigger another popover from the first popover by clicking on some content within it.

If you'd like to see a demonstration, check out this JSFiddle link.

While I am able to get a popover when clicking on labels, I'm running into an issue where clicking on Create new Label does not trigger a popover. Could there be a mistake in my JQuery code that needs fixing, or is this functionality simply not possible?

Answer №1

Give this code snippet a shot

$('[data-toggle="popover6"]').popover({
  html: true,
  placement: 'bottom',
  trigger: 'manual',
  content: function() {
    return $('#popover-card-content').html();
  }
});

$(document).on('click', '[data-toggle="popover6"]', function() {
  $(this).popover('toggle');
  $('[data-toggle="popover7"]').popover({
    html: true,
    placement: 'bottom',
    trigger: 'manual',
    content: function() {
      return $('#popover-card-wrapper2').html();
    }
  });
});

$(document).on('click', '[data-toggle="popover7"]', function() {
  $(this).popover('toggle');
});
.optionc {
  border-radius: 2px;
  background: #e2e4e6;
  -webkit-box-shadow: 0 1px 0 0 #c4c9cc;
  box-shadow: 0 1px 0 0 #c4c9cc;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  cursor: pointer;
  display: block;
  height: 32px;
  margin-top: 8px;
  max-width: 300px;
  overflow: hidden;
  padding: 7px 7px 7px 11px;
  position: relative;
  text-decoration: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  white-space: nowrap;
}

.optionc:hover {
  background-color: rgb(193, 193, 193);
  color: white;
  border: none;
  box-shadow: 0 0 2px 0 #c4c9cc;
}

.popover-header {
  position: relative;
  text-align: center;
}

.pop-over-list li>a {
  display: block;
  font-weight: 700;
  padding-top: 3px;
  position: relative;
  text-decoration: none;
  width: 265px;
}

.popover {
  width: 500px;
}

#searchlabel {
  background: rgb(226, 228, 230);
  border: 0;
  border-radius: 3px;
  -webkit-box-shadow: none;
  box-shadow: none;
  height: 30px;
  margin-left: 0;
  width: 250px;
  padding-top: 8px;
  ;
  overflow: hidden;
}

#searchlabel:focus {
  box-sizing: border-box;
  box-shadow: 0 0 2px 0 #0284c6;
  background-color: white;
}

.label {
  height: 80px;
  width: 250px;
  position: relative;
  margin-top: 20px;
}

.label:hover {
  background: rgb(226, 228, 230);
}
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="style.css">
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<a href="blog/2015/08/jquery-bootstrap-icons.download.html" data-icon="download-alt"></a>

<body>

  <div>
    <a class="optionc" class="card1" title="Labels" tabindex="0" data-trigger="focus" data-toggle="popover6">
      <span class="fa fa-tag">  </span>
      <span>
          <b style="color:rgb(68,68,68); font-size:15; padding-left:5px" >Labels</b>
       </span>
    </a>
  </div>

  <div id="popover-card-content">
    <textarea id="searchlabel" placeholder="Search Labels..."></textarea>
    <ul style="margin-bottom:20px; padding:0; list-style: none;" class="pop-over-list">
      <li class="hover1">

      </li>
    </ul>
    <div class="label" style="font-size:12px;"><a title="Create Label" tabindex="0" data-trigger="focus" data-toggle="popover7">Create new Label</a></div>
    <hr>
    <div class="label" style="font-size:12px"><a>Enable color blind friendly mode</a></div>
  </div>
  <div id="popover-card-content1">
    <b>Name</b>
    <textarea id="searchlabel"></textarea>
    <b>Select a color</b>
    <span style="background-color:rgb(97,189,79); width:50px; height:30px; margin-right:3px; border-radius:3px;"></span>
  </div>
</body>

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

Simple user interface height to occupy the entire browser window

Adding Tabs Dynamically ... I am attempting to design a layout using this example ... however, the issue is that the page does not utilize the full height and width of the available space... I have attempted adjusting the width and height to 100% of the ...

Refine results by searching through the text contained in the elements of every div

I recently came across a helpful fiddle that allows text to be hidden based on what is entered into a search box. However, I am struggling to apply this method to a div that contains multiple elements. Is there a way to modify the jQuery in the provided fi ...

"Woops! An error occurred with the message: "SassError: Could not locate the specified target selector" while working with SCSS Modules and incorporating

Currently, I am working with Next.js and utilizing SCSS Modules. To incorporate Bootstrap into my project, I opted to install it using the command npm install bootstrap. Following this installation, I went ahead and created a new file titled common.scss wi ...

Exploring the World of Micro-Frontends with the Angular Framework

I am conducting research on the best methods for transitioning a large single-page application into a micro-frontend architecture. The concept: The page is made up of multiple components that function independently Each component is overseen by its own ...

Click to dynamically change the input number variable

I'm in the process of creating a special calculator, where you input the number of years into a field, hit submit, and see different results displayed below without the page reloading. All my calculations are working properly at the moment. However, ...

Utilize Vue.JS to showcase JSON information from an external file

Currently, I have a View.JS app that displays a conversation thread from a JSON file. The existing code appears as follows: const app = new Vue({ el: "#app", data: { messages:[ { name: "Support", message: "Hey! Welcome to suppo ...

Can you explain the distinction between these two jQuery selectors?

Is the result of $('#e > #f') the same as $('#e #f') when using this markup: <div id="e"> <div id="f"></div> </div> ...

Is there a way to retrieve all div elements within a specific div using webdriver and selenium?

As a newcomer to the world of web scraping, I am currently working on scraping a website in order to extract all elements with the data-feature-id=homepage/story. My ultimate goal is to access a subelement within each of the divs contained in the parent el ...

Ways to fetch a JSON object using JavaScript

Currently, I am in the process of creating an HTML5 mobile application and utilizing jQuery to fetch a JSON file from this URL: . Here is the code snippet I used: var url='http://cin.ufpe.br/~rvcam/favours.json'; $.getJSON(url, function(data, s ...

Antonio Mele's latest book on Django3 and Ajax Button Development

After clicking the like button, it shows a count of 2099 instead of 1. However, after refreshing the page, it displays the correct count of 1. The same issue occurs when unliking. The count is accurate only after a refresh, otherwise, it randomly shows eit ...

What is the best way to eliminate excessive margin-bottom on a floating image?

Is it possible to maintain the same margin at the right and bottom of an image when using <img> inside <p><img style="float:left">dummy text dummy text dummy text dummy text</p>? ...

Unable to detect HTML special characters in the text

In my current task, I am facing the challenge of matching two URLs. One URL is retrieved from a MySQL database, while the other one is sourced from an HTML page. When comparing both URLs as strings using Regex, the result shows match.Success = false. Despi ...

What is the process of retrieving user input from an HTML form and locating specific data within it?

Here is the structure of my form: <div id="employeeinfo" style="padding:40px" class="employee-body"> <form id="employeeform" title="" method="post"> <label class="title">First Name</label> < ...

I'm looking for a method in JavaScript that can search through my XML file to locate specific attributes and return the entire parent element containing that attribute. Can anyone help with

I'm completely new to XML and Javascript. I currently have this code in my HTML file: <select id="eigenschaften" name="eigenschaften" type="text" onchange=""> <option value="">Choose Property</option> <option value="soci ...

Does the input password typically submit on its own?

When attempting to create a form, I encountered an unexpected behavior. <form> <input type="text" autocomplete="username" style="display:none;"> <label for="password">password:</label><input type="password" autocomplete="c ...

Preload-webpack-plugin does not support pre-fetching files

I have a query about prefetching and preloading content. In my vue app, I noticed that after building, I have duplicate files loaded in my dist/index.html file. Here is an example: Additionally, the "scripts" are not being preloaded/prefetched as expec ...

When the page is zoomed in, the Bootstrap navbar overlaps with

I'm currently in the process of developing a website that includes a navbar with a navbar-fixed-top class. Everything seems to be working perfectly except for when I zoom in. On mobile devices, when I zoom in, the navbar starts wrapping and goes to th ...

Issue with CSS not appearing in Google Chrome's coverage tab

As I delve into analyzing the extent of unused CSS on my webpage, I encounter a challenge. The webpage is crafted in Angular 7, with CSS incorporated through the angular.json build configuration. The css appears to be added to the head of the html file, e ...

Altering the href text within a script causes the text to disappear instead of updating

Function Triggered by Button Click: function LoadEnglishText() { document.getElementById("txt_whatwedo_learnmore2").innerHTML = "here."; } HTML Link to be Updated: <a id="txt_whatwedo_learnmore2" href="./pdf/Pricing_App_Dev_2019_Ger.pdf">hier ...

An empty canvas with jQuery being added

After successfully integrating jQuery into my PHP script, I encountered an issue where the page goes blank once the jQuery script is added. Below is the code snippet causing the problem: function site_header() { echo "<html dir=\"rtl\"&g ...