Reputation: 107
I have 2 file.php, file1.php it is a file for the core page, file2.php to display the added form. file2.php included to file1.php in a statement. when i need to use function from Boostraps.js, to beautify tooltip, i call function from Boostraps.js in file1.php as follows:
$('.Btn').Tooltip({
placement: 'bottom'
});
why tooltip() function only runs on file1.php only, does not work for file2.php included in file1.php how to keep this tooltip function running in 2 different files that are included. if calling globally I've used action just like this:
$(document).on('click',function(){
// Bla bla bla ...
})
Upvotes: 0
Views: 251
Reputation: 573
So what you want to do right now use that both 2 file php at the same time/page?
If you want do something like set it globally without need to set it again.
Maybe you can try check this code.
$(document).on("mouseover",".btn",function(){
var ele = $(this);
if(!ele.data("setthis")){ // check it. so we only bind only once
$(this).tooltip({
placement: 'bottom'
});
$(this).tooltip("show");
ele.data("setthis",true); // set this to true, don't set it anymore
}else{ // just a log. can delete it.
console.log("Don't Set Another Tooltip");
}
});
Just run it once in core page @ anything. And jsfiddle here : https://jsfiddle.net/synz/o8sue511/3/
Upvotes: 0
Reputation: 1279
You have 2 totally separate files, so how they should communicate to each other? Are they share a core? like wordpress CMS. If not you should include same js file into both php file otherwise it wont work.
This code:
$('.Btn').Tooltip()
means be global and every where in document you find this class .btn
turn it to tooltip, "BUT" when there is not .btn
in document "OR" you didn't add this code in that document, you will get anything and the code will not work.
Upvotes: 2