Opened 10 years ago
Closed 10 years ago
#8826 closed feature (wontfix)
Widget: ._on() equivalent of .one()
Reported by: | nix | Owned by: | nix |
---|---|---|---|
Priority: | minor | Milestone: | 1.10.0 |
Component: | ui.widget | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
It would be nice to have this so that, when hooking up a one-shot event, if the widget is destroyed before the event fires, the handler is removed.
Currently we'd have to call ._off() from the handler attached with ._on() to accomplish this.
Change History (5)
comment:1 Changed 10 years ago by
Owner: | set to nix |
---|---|
Status: | new → pending |
Summary: | Need a one-shot version of ._on() → Widget: ._on() equivalent of .one() |
Version: | git → 1.9.1 |
comment:2 Changed 10 years ago by
Status: | pending → new |
---|
In mobile's fixedToolbar, we implement toolbars that are persistent across pages by hooking a one-shot handler to the next page's "pageshow" event and attach the header/footer there.
https://github.com/jquery/jquery-mobile/blob/master/js/widgets/fixedToolbar.js#L159 (or look for '.one( "pageshow"' ).
Now, mind you, "pagebeforehide" is called shortly before "pageshow" for the next page, so chances are the .one() handler will indeed run, but there's still a possibility that the page will be destroyed before the next one shows.
comment:3 Changed 10 years ago by
Status: | new → pending |
---|
Is that the only place you would use it in jQuery Mobile? If so, I'm going to close as wontfix. While this case would be easy to handle, the case of using a named function reference via a string would not.
comment:5 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Can you provide some examples of when you need this?