Reputation: 25775
I'm using the qTip 1.0.0-rc3 plugin for jQuery. And, although it's not a big deal, I am curious as to why this works:
$(document).ready(function() {
if (jQuery().qtip) {
$('[data-qtip]').each(function() {
var qTipContent = $(this).attr("data-qtip");
$(this).qtip({ content: qTipContent });
});
}
});
and this does not work:
$(document).ready(function() {
addToolTips();
});
function addToolTips() {
if (jQuery().qtip) {
$('[data-qtip]').each(function() {
var qTipContent = $(this).attr("data-qtip");
$(this).qtip({ content: qTipContent });
});
}
};
The former is being invoked within a function and the latter is not. Here is the error message from Firebug:
f(this).data("qtip") is null
I'm sure it's something stupid, but what am I missing?
Thanks.
Upvotes: 1
Views: 192
Reputation: 25775
Wow, I feel stupid. I just found there was a hidden conflict in another one of my local files. I knew everything looked right! Thanks for the help.
Upvotes: 1
Reputation: 33697
The code you have given, is it executed in the "global scope" or is it wrapped by { and } (in another function or something)?
Upvotes: 1