I am using tooltipster plugin to create tooltips.
When tool tip are shown up, if you then click on the background (pink) - it will alert you ID from data-post-id='xx'
that has been closed (functionAfter
). It is showing the correct ID.
However, instead of clicking on the background (pink) and if you click on any other Tips, it will show you incorrect ID. What is causing this and how to fix?
See Demo: http://jsfiddle.net/ww60y38h/
$(".tip").tooltipster({
content: 'Loading...',
contentAsHTML: true,
offsetY: -13,
autoClose: true,
theme: 'tooltipster-punk',
trigger: "click",
onlyOne: true,
multiple: false,
interactive: true,
functionBefore: function(origin, continueTooltip) {
continueTooltip();
postID = $(this).data('post-id');
origin.tooltipster('content', "Post ID: " + postID);
},
functionAfter: function(origin) {
alert("PostID Tooltip Closed:" + postID);
}
});
HTML:
<div style="height: 900px; background-color:pink">
<div class="tip" data-post-id='1'>ToolTip PostID 1</div>
<div class="tip" data-post-id='2'>ToolTip PostID 2</div>
<div class="tip" data-post-id='3'>ToolTip PostID 3</div>
</div>