JavaScript How to trigger a bootstrap popover on mouseover event trigger bootstrap popover,trigger bootstrap popover on hover,bootstrap trigger

I have a html table with a row that looks like:

<tr>
    <td><input type="checkbox" name="check[]" value="265"></td>   
    <td>265</td>
    <td>NO MATCH</td>
    <td>http://stackoverflow.com/</td>
    <td>No</td>
    <td>0</td>
    <td>f79a8316891</td>
  </tr>

I am trying to build a jquery function that will open up a bootstrap 2.32 popover if I pass it over a URL in table cell. So far I have:

    $("[data-bind='popover']").popover({
         trigger: 'hover',
         html: true,
         content: function(){ 
          return $(this).data('content');
         }
        });



        $('td').on('mouseover', function(e) {
            var contents = $( this ).html() ;

            if (contents.match("^http")) {
                console.log(contents);

                 this.innerHTML = '<a target='_blank' href="myreference.html" data-bind="popover"' + ' data-content="'+contents +'"> link </a>';
                 console.log(this.innerHTML);

            }
        });

The popover portion of this is based on http://jsfiddle.net/8DP4T/1/

When I mouseover a url in the table it forms a popover link as expected. However as I hold the mouse over it no popup occurs as far as I can see. The code does work , but it is not triggering the popover.

Interestingly , I have also placed

<a target='_blank' href="myreference.html" data-bind="popover data-content="http://upload.wikimedia.org/wikipedia/commons/a/a5/Flower_poster_2.jpg">Brick</a> 

below my table and this is working with a popover created. I'm wondering if this behavior has something to do with the order of operations because the popover link is created dynamically after the DOM is already set. Can someone advise me here?

Answer:1

The default trigger for a bootstrap popover is a 'click' event. What you've defined here is "On mouseover, check to see if the content under my mouse is a link, and if so, define a popover", but your problem is that you never triggered the popover to open, you just defined it so that if it's click it'll open.

Change this...

$('.popover-markup').popover(...)

To this...

$(this).popover(...)

So that the "<td>" becomes the popover (I'm not 100% certain you can define a <td> as a popover, but it seems like it should work). Then, immediately after your code that defines the popover options, you can trigger a "click" event, or you can trigger it to open by sending the "show" command. Finally, you can trigger it to open by adding "trigger":"hover" to your options list when defining the popover... which will auto-hide it after the user is no longer hovering over the td element.

//Trigger click
$(this).trigger("click");

//Trigger popover open (probably the better way)
$(this).popover("show");

//Trigger on hover
$(this).popover({
    ...
    trigger: 'hover',
});

So in all...

$('td').on('mouseover', function(e) {
     var contents = $( this ).html() ;

    if (contents.match("^http")) {
       $(this).popover({
            html : true,
            title: function() {
              return $(this).parent().find('.head').html();
            },
            content: function() {
              return $(this).parent().find('.content').html();
            },
            container: 'body',
            placement: 'bottom'
        });

        // Trigger the popover to open
        $(this).popover("show");
    }
});
Answer:2

I'm following a book, and using this version of Angular: https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.js[1] This is my template: <div ng-controller="ParentController"> <...

I'm following a book, and using this version of Angular: https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.js[1] This is my template: <div ng-controller="ParentController"> <...

  1. angular scope binding symbols
  2. angularjs scope binding directive
  3. angularjs scope bindings
  4. angularjs scope binding not updating
  5. angular scope binding types
  6. angular scope binding directive
  7. angular directive scope binding types
  8. angular 1 scope binding
  9. angular isolate scope binding
  10. angular optional scope binding
  11. angular scope not binding
  12. angular directive scope binding array
  13. angular 1 directive scope binding
  14. angularjs directive scope binding
  15. angular scope variable not binding
  16. angular scope one way binding
  17. angular scope two way binding
  18. angular data binding scope
  19. angular directive scope optional binding

I have a div that I need to hide when an option is selected in an option, below is my current html: Type:<select name="Type" id="Type"> <option value="choice">Multiple choice</...

I have a div that I need to hide when an option is selected in an option, below is my current html: Type:<select name="Type" id="Type"> <option value="choice">Multiple choice</...

  1. hide when minimized option
  2. hide option in select jquery
  3. hide option in select
  4. hide option in excel
  5. hide option to switch to salesforce classic
  6. hide option in select javascript
  7. hide option menu android
  8. hide option
  9. hide option jquery
  10. hide option in whatsapp
  11. hide option value in select
  12. hide option select2
  13. hide option menu in fragment
  14. hide option html
  15. hide option menu item android
  16. hide option from dropdown jquery
  17. hide option in select html
  18. hide option on facebook
  19. hide option in tally
  20. hide option javascript

So I want to swap two div elements that have a CKEditor inside. I viewed some of the previous questions and tried to do it that way. It's all OK, the elements are swapped. But one of the elements ...

So I want to swap two div elements that have a CKEditor inside. I viewed some of the previous questions and tried to do it that way. It's all OK, the elements are swapped. But one of the elements ...

  1. swap elements js
  2. swap array elements javascript
  3. swap html elements javascript
  4. swap dom elements javascript
  5. swap two elements javascript
  6. swap array elements javascript es6
  7. swap two array elements javascript
  8. swap elements in list javascript

Cache all requests from an app without explicitly specifying urlsToCache. So I will cache stuff under fetch event. To respond to requests from the cache. Update the cache when fetch is success. ...

Cache all requests from an app without explicitly specifying urlsToCache. So I will cache stuff under fetch event. To respond to requests from the cache. Update the cache when fetch is success. ...

  1. when should you write a functional (skills) résumé
  2. when should you write out numbers
  3. when should child write name
  4. when should i write my birth plan
  5. when should you write numbers as words
  6. when should child write their name
  7. when should you write the executive summary
  8. when should you write a business plan
  9. when should you write a cover letter
  10. when should you write the introduction and overview portion
  11. when should i write out numbers
  12. when should you write without prejudice on a letter
  13. when should you write a draft of your summary
  14. when should i write gre for fall 2020
  15. when should i write my college essay
  16. when should i write a cover letter
  17. when should i write numbers as words
  18. when should we write gate exam