Opened 7 years ago

Closed 7 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 7 years ago by Scott González

Owner: set to nix
Status: newpending
Summary: Need a one-shot version of ._on()Widget: ._on() equivalent of .one()
Version: git1.9.1

Can you provide some examples of when you need this?

comment:2 Changed 7 years ago by nix

Status: pendingnew

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 7 years ago by Scott González

Status: newpending

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:4 Changed 7 years ago by nix

Status: pendingnew

I guess that's fine ...

comment:5 Changed 7 years ago by Scott González

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.