Search code examples
jqueryqtipqtip2

qtip jquery click not invoking on element inside tooltip


I'm using jquery qtip (http://qtip2.com/)

its working well, i have a number of divs inside with classes

I'm trying to to invoke a click function on these divs

qtip:

 var tipContent = $('#tip-content').html();
    $('#obsglass').qtip({
        content: {
            text: tipContent
        },
        show: {
            effect: function() {
                $(this).fadeTo(500, 1);
            },
            event:'click'
        },
        hide: {
            effect: function() {
                $(this).slideUp();
            },
            event:'click unfocus'

        },
        //show: 'click',
        //hide: 'click unfocus',
        style: {
            classes: 'qtip-bootstrap qtip-shadow',

        },

        position: {
            my: 'center left',  // Position my top left...
            at: 'center right', // at the bottom right of...
            target: $('#obsglass') // my target
        },


    });

Click function

 $(".obsglass-thumbnail").click(function () {

... Not entering this function when clicking the divs in the tool tip


Solution

  • Seem like your elements have been added dynamically to the DOM by the plugin, try to use event delegation here:

    $(document.body).on('click','.obsglass-thumbnail',function() {
        // Your code here
    })