Skip to content

Unload: update outdated example#639

Closed
arthurvr wants to merge 2 commits into
jquery:masterfrom
arthurvr:unloadExample
Closed

Unload: update outdated example#639
arthurvr wants to merge 2 commits into
jquery:masterfrom
arthurvr:unloadExample

Conversation

@arthurvr
Copy link
Copy Markdown
Member

Would fix #388.

@mgol
Copy link
Copy Markdown
Member

mgol commented Jan 28, 2015

I'd also add a note that in Firefox (and maybe in some other places?) a message is ignored.

@arthurvr
Copy link
Copy Markdown
Member Author

I'd also add a note that in Firefox (and maybe in some other places?) a message is ignored.

I thought about it, but are jQuery API docs the right place to teach people JavaScript? This isn't a jQuery specific behaviour.

@mgol
Copy link
Copy Markdown
Member

mgol commented Jan 28, 2015

We're already making this event special by setting returnValue by ourselves; people using the event directly have to know that. Since we're taking some responsibility off users, I think we should inform them we're not fixing everything. :)

What do you think, @dmethvin?

Comment thread entries/unload.xml Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/alert/message/ maybe?

s/will be/may be/ as well?

@dmethvin
Copy link
Copy Markdown
Member

I believe we've gotten bug reports about this in the past, so perhaps we can add something to the warning already there.

@arthurvr
Copy link
Copy Markdown
Member Author

Just for the reference, dropping in jquery/learn.jquery.com#608 too. Might be worth it to mention it there.

@arthurvr
Copy link
Copy Markdown
Member Author

I believe we've gotten bug reports about this in the past, so perhaps we can add something to the warning already there.

Added a sentence warning about it. I don't think we should go in-depth. @dmethvin What do you think?

Comment thread entries/unload.xml Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tab? ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops! Fixed!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mzgol Does the rest LGTY?

@mgol
Copy link
Copy Markdown
Member

mgol commented Jan 31, 2015

What about the info that some browsers will ignore the message at all?

@dmethvin
Copy link
Copy Markdown
Member

I agree the comments here should be kept simple and not go too deep. It's always a bit frustrating when an API reference turns into a big "how to write JavaScript in the browser" article. Fortunately this page is pretty short at this point so we're not adding that much more to read.

This event is available so that scripts can perform cleanup when the user leaves the page.

This is a great point, maybe move this to the beginning in its own paragraph? That brings up the async operation trap, so perhaps add a sentence after it like, "Note that the browser may cancel or deny asynchronous operations attempted in this handler, such as AJAX or setTimeout."

Depending on the browser, the message you return will be used in a confirmation dialog.

Maybe something like this instead? "The string you return may be used in a browser confirmation dialog, but not all browsers support this." The warning already covers this ground again so I don't think we need much more.

@mgol
Copy link
Copy Markdown
Member

mgol commented Jan 31, 2015

@dmethvin That sounds good. :)

Michał Gołębiowski

@arthurvr
Copy link
Copy Markdown
Member Author

arthurvr commented Feb 2, 2015

@mzgol @dmethvin Updated PR.

@dmethvin
Copy link
Copy Markdown
Member

dmethvin commented Feb 2, 2015

LGTM!

@arthurvr arthurvr closed this in e82e9db Feb 2, 2015
@arthurvr arthurvr deleted the unloadExample branch February 2, 2015 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

The unload docs have incorrect examples.

3 participants