Sconny
Sconny

Reputation: 25

Manual close event on delegated jQuery UI tooltip

Trying to manually close tooltip using link in tooltip, however, since it's a delegated tooltip, I'm unable to achieve this.

See jsfiddle: http://jsfiddle.net/YhV5B/

$('#ui-tooltip-0').delegate('.tooltip-close', 'click', function(e) {
    alert("yes");
    var $this = $(e.target);
    $(this).tooltip('close');
});

Any help would be appreciated.

Thanks

Upvotes: 1

Views: 993

Answers (1)

Mukesh
Mukesh

Reputation: 858

you should track the event target:

$('body').on('click', function(e){
        var myTarget = e.target;
        if( $(myTarget).attr('class') === 'tooltip-close' ){
            $('.tooltip-open').tooltip('close');
        }        
    });

I have updated the code on Fiddle

Upvotes: 1

Related Questions