16th April, 19:56
Thanks, Craig, for all your great work!
I am having problems adding a click event to the qTip title. I want the qTip content to slideUp when I click the qTip title and then slideDown on the next click. I tried both the toggle and click events on the qTip title, using the onShow API. In addition, when I was investigating, I noticed that when I click on the target element to show the qTip, it appears that onShow is triggered twice for one click (Do I see that in the show API source code, onShow() called in afterShow() once and then again later?).
I tested in Firefox 2 and 3 and IE 7.
Any help/info would be appreciated.
Thanks again.
I am having problems adding a click event to the qTip title. I want the qTip content to slideUp when I click the qTip title and then slideDown on the next click. I tried both the toggle and click events on the qTip title, using the onShow API. In addition, when I was investigating, I noticed that when I click on the target element to show the qTip, it appears that onShow is triggered twice for one click (Do I see that in the show API source code, onShow() called in afterShow() once and then again later?).
I tested in Firefox 2 and 3 and IE 7.
Any help/info would be appreciated.
JS Code
<html>
<head>
</head>
<body>
<h3>This example works as expected (jQuery only, no qTip).</h3>
<div id='parent'>
<div id='standard_title'>Title: <b>click me</b> to toggle content</div>
<div id='standard_content'>Here is the content.</div>
</div>
<h3>These examples do not work as I expect (jQuery + qTip).</h3>
<ul>
<li>A click on the tooltip title appears to happen twice, if I use the toggle event.</li>
<li><span id='qtip_toggle_event'><b>Click me</b> for a qtip (version 1)</span></li>
<li>And, a click on the tooltip title appears to happen twice (sometimes more), if I use the click event.</li>
<li><span id='qtip_click_event'><b>Click me</b> for a qtip (version 2)</span></li>
<li>Also, onShow appears to happen twice</li>
</ul>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="/jquery/jquery.qtip.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
// ======================
jQuery('#standard_title').toggle(
function(event) {
alert('click');
jQuery('#standard_content').slideUp('normal');
},
function(event) {
alert('click');
jQuery('#standard_content').slideDown('normal');
}
);
// ======================
jQuery('#qtip_toggle_event').qtip({
content: {
text: 'This is the qTip content: version 1.',
title: {
text: 'qTip Title: click me to toggle content (using toggle event)'
}
},
show: 'click',
hide: 'click',
api: {
onShow: function() {
alert('onShow');
var self = this;
// hide/show the content by clicking on the title
// ----------------------------------------------
// version 1
jQuery(self.elements.title).toggle(
function(event) {
alert('click');
jQuery(self.elements.content).slideUp('normal');
},
function(event) {
alert('click');
jQuery(self.elements.content).slideDown('normal');
}
);
}
}
});
// ======================
jQuery('#qtip_click_event').qtip({
content: {
text: 'This is the qTip content: version 2.',
title: {
text: 'qTip Title: click me to toggle content (using click event)'
}
},
show: 'click',
hide: 'click',
api: {
onShow: function() {
alert('onShow');
var self = this;
// hide/show the content by clicking on the title
// ----------------------------------------------
// version 2
jQuery(self.elements.title).click(function() {
alert('click');
jQuery(self.elements.content).slideToggle('normal');
});
}
}
});
});
</script>
</body>
</html>Thanks again.
