To add to HurnsMobile's excellent answer; Looking at bindReady()
, which is the internal call that jQuery makes to bind to the document load event every time you call $(some_function)
or $(document).ready(some_function)
we see why we cannot bind to "ready"
:
bindReady: function() {
if ( readyBound ) {
return;
}
readyBound = true;
// Catch cases where $(document).ready() is called after the
// browser event has already occurred.
if ( document.readyState === "complete" ) {
return jQuery.ready();
}
// Mozilla, Opera and webkit nightlies currently support this event
if ( document.addEventListener ) {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
// A fallback to window.onload, that will always work
window.addEventListener( "load", jQuery.ready, false );
// If IE event model is used
} else if ( document.attachEvent ) {
// ensure firing before onload,
// maybe late but safe also for iframes
document.attachEvent("onreadystatechange", DOMContentLoaded);
// A fallback to window.onload, that will always work
window.attachEvent( "onload", jQuery.ready );
// If IE and not a frame
// continually check to see if the document is ready
var toplevel = false;
try {
toplevel = window.frameElement == null;
} catch(e) { //and silently drop any errors
}
// If the document supports the scroll check and we're not in a frame:
if ( document.documentElement.doScroll && toplevel ) {
doScrollCheck();
}
}
}
To sum it up, $(some_function)
calls a function which binds to:
- DOMContentLoaded
- onreadystatechange (DOMContentLoaded)
- window.load / onload
Your best bet would be to bind to those actions that might create new .tooltipper
elements, rather than trying to listen for the ready event (which happens only once).
.live()
? I think you would probably be better off trying to bind it to the event that would potentially create newselector
's. Not directly an answer but it seems like sort of a shotgun approach to use.live()
onready
. Just my $.02. – Aquamarinehref
attribute should always take you to a URL when clicked. Most elements with atitle
attribute should display the parameter as a tooltip on mouse over. It only makes sense to me to enable this sort of functionality to higher-order behaviours, like custom tooltipping. – Muncey$('.tooltipper').livequery(function(){$(this).tooltip()})
, which makes the most semantic sense to me (as opposed to the next best solution, which is to add the callback to the function that creates the tooltip element) in that the tooltip behaviour is associated with the element---it has nothing to do with the process by which it is created. – Muncey