How can I define a one-time event so that new handlers fire (once) even after the event has already occurred?
- by harpo
You know how this
$(function() { ... });
will fire whether or not the "document ready" event has already occurred? I want to define an event like that.
That event is a special case in jQuery. I'm wondering if a custom event can behave in the same way, using only the standard event mechanisms.
Ideally, I'd like to be able to define handlers in the "normal" way:
$(document).on("init.mything", function() { ... });
This works now if the above runs before init.mything is triggered. But if it doesn't, then the handler never runs.
What makes this tricky is, I don't want to assume anything except that jQuery has loaded.
Any ideas?