Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap .popover('show'), .popover('hide') not working. Binding it to click works

I have a button that has been binded to a popover. I would like to hide the popover when someone clicks on one of the smilies in the popover. However, $("#smiley").popover('hide') does not work.

Unfortunately I haven't been able to reproduce this with barebones code - it only happens on the live site, which is https://coinchat.org

Relevant code:

$("#smiley").popover({html: true, trigger: 'click', placement: 'top', content: smileyContent, title: 'Smilies'});

Later in a function..

$("#smiley").popover('hide'); // not working
like image 903
apscience Avatar asked Jul 31 '13 11:07

apscience


1 Answers

In https://inputs.io/js/buttons.js the jQuery plugin jQuery.fn.popover is overwritten on a load event of some kind, so $("#smiley").popover("hide") at that point is no longer calling into bootstrap but the plugin provided by inputs.io.

A snippet of the code:

Inputsio.load = function(){
    (function(){(function(e){return e.fn.popover=function(t)

The usage of jQuery plugin namespace for application specific code is extremely distasteful indeed.

A temporary fix could be $("#smiley").click()

like image 167
Esailija Avatar answered Sep 30 '22 00:09

Esailija