I have two button +
and -
. When I click on +
button I am adding one div in parent div and want to show tooltip on that div when I click again on +
button then I am adding again one div and want to show tooltip on second div only. It's same for upto 7 div.
Currently I am doing same but when I add more than one div tooltip will not hide for previous button and will still there. So at end I am seeing all 7 tooltip but I supposed to see last div tooltip only.
I tried to hide it after some delay but even it's not working.
Here is my code.
function init(){
for(var divCount = 1; divCount <= fanSpeed; divCount++){
$('#temperature_bar').append('<div style="float:left" data-tooltip-id="'+divCount+'" id="speed_"'+divCount +'" class="trigger climate-fan-bar" onclick="\buttonTempraturePressed(this.id)\" title="<div class="row row-thumbnail" id="box-search"><div class="thumbnail text-center"><img width="50" height="50" src="images/fan_speed_bg_center_popup.png" class="img-responsive"><div class="caption"><span class="tooltip-text-size">' + divCount + '</span></div></div></div></div>' );
showTooltips("speed_"+divCount);
}
}
function showTooltips(clicked_id){
//show
$(clicked_id).on('click', '.trigger', function () {
$(this).addClass("on");
$(this).tooltip({
hide: { effect: "flip", duration: 1000 },
items: '.trigger.on',
position: {
my: "top",
at: "top",
collision: "flip"
}
});
$(this).trigger('mouseenter');
});
/*$(clicked_id).on('click', '.trigger.on', function () {
$(this).tooltip('close');
$(this).removeClass("on");
});*/
//prevent mouseout and other related events from firing their handlers
$(".trigger").on('mouseout', function (e) {
e.stopImmediatePropagation();
});
}
onclick="\buttonTempraturePressed(this.id)\"
should be replaced byonclick="buttonTempraturePressed(this.id);"
. – Borglum" id="speed_"
by" id="speed_
(the closing"
is supplied later in your concatenation). – Borglumtitle="<div ...
part, some double quotes should probably be escaped. I can't tell which ones, since I couldn't quite figure out what is supposed to be included in that attribute. You may try to simplify that part and then make a jsfiddle with the minimal code. – Borglummouseout
event? – Differentiation