Twitter Bootsrap: Popover and Auto Refresh

I use Twitter Boostrap with website reorganization and I need jQuery help. I use the "Popover" add-in, which is packaged in bootstrap, and I have it in the #div tag (specific #onlineata specification), and I use jquery to reload the div every 10 seconds. This works great, however, if you accidentally hover over a link that activates popover, when the div is updated, popover gets stuck.

I use this code to update:

setInterval(function(){
        $("#onlinedata").load("http://website.com #onlinedata");
}, 10000);

And if necessary, the code that activates popover:

$(function () {
        $('a[rel=popover]').popover({
            placement:'right',
            title:'Title',
            content: $('#div-that-contains-data').html()
        });
});

Is there a way to avoid popover blocking when reloading a div?

Any help is greatly appreciated.


HTML related

$id is the key for every popover, because I have several popovers.

, , popover_controller:

<div id="controller_popup_$id" style="display:none;">
   <div style="font-size:11px">
       //data_fetched_from_database
   </div>
</div>

, popover

<li><a href="#" rel="popover_controller_$id">Link Title</a></li>

, , javascript, ( , javascript):

$(function () {
    $('a[rel=popover_controller_$id]').popover({
          placement:'right',
          title:'Title (this is fetched from the database for each popover)',
          content: $('#controller_popup_$id).html()
    });
});
$(document).ready(function() {
    // refreshing code
    setInterval(function() {
        $('#controller_popup_$id').hide(); // close any open popovers
        // fetch new html
        $('#onlinedata').load('http://website-link.com #onlinedata', function() {
            // after load, set up new popovers
            $('a[rel=popover_controller_$id]').popover({
                placement:'right',
                title:'Title (this is fetched from the database for each popover)',
                content: $('#controller_popup_$id').html()
            });
        });
    }, 10000); // 10 second wait
});

** **

, . , , - div #onlineata, popover.

$(document).ready(function() {
        $('a[rel=popover_controller_$id]').popover({
            placement:'right',
            title:'Title',
            content: $('#controller_popup_$id').html()
        });
        // refreshing code
        setInterval(function() {
            // fetch new html
            $('a[rel=popover_controller_$id]').load('http://websiteurl.com/ #onlinedata', function() {

                $('a[rel=popover_controller_$id]').popover('destroy'); // remove old popovers
                // after load, set up new popovers
                $('a[rel=popover_controller_$id]').popover({
                    placement:'right',
                    title:'Title',
                    content: $('#controller_popup_$id').html()
                });

            });
        }, 10000); // 10 second wait
});

+5
1

, , DOM, load -ed. popover load. , , , . :

$(document).ready(function() {
    // refreshing code
    setInterval(function() {
        $('a[rel=popover]').popover('destroy'); // remove old popovers
        // fetch new html
        $('#onlinedata').load('/onlinedata.html #onlinedata', function() {
            // after load, set up new popovers
            $('a[rel=popover]').popover({
                placement:'right',
                content: $('#div-that-contains-data').html()
            });
        });
    }, 10000); // 10 second wait
});
0

All Articles