qTip (jQuery plug-in) how can I remove all qtips in my page?

后端 未结 10 1924
醉话见心
醉话见心 2021-02-04 00:30

I\'m using the jquery-plugin qTip. What\'s the command to destroy all tooltips in my page ?

I tried:

$(\'.option img[title], span.taxonomy-image-link-al         


        
10条回答
  •  南方客
    南方客 (楼主)
    2021-02-04 01:05

    It may be a little late, but I had issues with memory and page load when an ajax call replace the content in the page, deleting the target qtip2 objects before destroy them, so some elements remains even if the target had gone.

    Based on the fact that sometimes you want to clean all qtips2 elements and data, no matter if the original object exist or not, some tooltip elements remains on the body, so when the original target has gone there is no easy way to call the destroy() method.

    Unless you do it searching for the created objects instead of the targets.

    jQuery('div[id^="qtip-"]').each(function(){ //search for remaining objects
    
        _qtip2 = jQuery(this).data("qtip"); //access the data where destroy() exist.
    
        //if it's a proper qtip2 object then call the destroy method.
        if(_qtip2 != undefined){ 
            // the "true" is for immediate destroy
            _qtip2.destroy(true);
        }
        //if everything went right the data and the remaining objects in the body must be gone.
    });
    

    I used JQuery for a no conflict issue, but you can use "$" (symbol) instead of JQuery

提交回复
热议问题