Modify

#10656 closed enhancement (fixed)

Prompt with a warning dialog when navigating away from a page with unsaved changes to an enum list

Reported by: rjollos Owned by: rjollos
Priority: normal Component: AdminEnumListPlugin
Severity: normal Keywords:
Cc: jun66j5 Trac Release:

Description

When items in the list have been reordered, but the changes haven't yet be saved, a warning should be issued when navigating away from the page. As an example, the BacklogPlugin has this behavior.

Attachments (1)

t10656-beforeunload-jquery1.2-r12424.diff (1.6 KB) - added by jun66j5 22 months ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 22 months ago by rjollos

  • Cc jun66j5 added
  • Owner changed from nonplus to rjollos
  • Status changed from new to assigned

comment:2 Changed 22 months ago by rjollos

  • Summary changed from Add a warning when navigating away from a page that has unsaved changes to Prompt with a warning dialog when navigating away from a page with unsaved changes to an enum list

comment:3 Changed 22 months ago by rjollos

I'd like to prompt with the dialog when Remove selected items is pressed, but not when Apply changes is pressed. I'm currently following the guidance in the first reply here.

comment:4 Changed 22 months ago by rjollos

(In [12419]) Refs #10656:

  • Prompt user with a dialog when navigating away from a page with unsaved changes to a list.
  • Added a changelog.

comment:5 follow-up: Changed 22 months ago by rjollos

[12419] doesn't seem to be working correctly with Trac 0.11.

Changed 22 months ago by jun66j5

comment:6 in reply to: ↑ 5 ; follow-up: Changed 22 months ago by jun66j5

Replying to rjollos:

[12419] doesn't seem to be working correctly with Trac 0.11.

Yes, beforeunload event doesn't work on jQuery 1.2. It works on 1.4. See http://bugs.jquery.com/ticket/4106.

Proposal patch is here, t10656-beforeunload-jquery1.2-r12424.diff. It checks existence of jQuery.event.special.beforeunload. See http://benalman.com/news/2010/03/jquery-special-events/#version-compatibility and http://docs.jquery.com/Events/jQuery.Event#Special_Events.

comment:7 in reply to: ↑ 6 ; follow-up: Changed 22 months ago by rjollos

Replying to jun66j5:

Proposal patch is here, t10656-beforeunload-jquery1.2-r12424.diff.

Thanks! Supporting these older versions of jQuery is a pain.

I was trying, but could not understand the need for:

$(window).bind('unload', function() { window.onbeforeunload = null; });

Any hints as to why that is needed?

comment:8 Changed 22 months ago by rjollos

(In [12436]) Refs #10656: beforeunload event is not supported in jQuery < 1.4, so some special handling is needed to directly utilize the window.onbeforeunload event in the cases that the jQuery special event is not supported. Patch by Jun Omae (jun66j5).

comment:9 in reply to: ↑ 7 ; follow-up: Changed 22 months ago by jun66j5

Replying to rjollos:

I was trying, but could not understand the need for:
$(window).bind('unload', function() { window.onbeforeunload = null; });

This code is avoiding memory leak risk on Internet Explorer.

comment:10 in reply to: ↑ 9 Changed 22 months ago by rjollos

Replying to jun66j5:

This code is avoiding memory leak risk on Internet Explorer.

In [12458] I added a note to the source code about this.

comment:11 Changed 20 months ago by rjollos

  • Resolution set to fixed
  • Status changed from assigned to closed

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.