Modify

Opened 5 years ago

Closed 4 years ago

Last modified 21 months ago

#10656 closed enhancement (fixed)

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

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Component: AdminEnumListPlugin
Severity: normal Keywords:
Cc: Jun Omae 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 Jun Omae 5 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 5 years ago by Ryan J Ollos

Cc: Jun Omae added; anonymous removed
Owner: changed from Stepan Riha to Ryan J Ollos
Status: newassigned

comment:2 Changed 5 years ago by Ryan J Ollos

Summary: Add a warning when navigating away from a page that has unsaved changesPrompt with a warning dialog when navigating away from a page with unsaved changes to an enum list

comment:3 Changed 5 years ago by Ryan J Ollos

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 5 years ago by Ryan J Ollos

(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 Changed 5 years ago by Ryan J Ollos

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

Changed 5 years ago by Jun Omae

comment:6 in reply to:  5 ; Changed 5 years ago by Jun Omae

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 ; Changed 5 years ago by Ryan J Ollos

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 5 years ago by Ryan J Ollos

(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 ; Changed 5 years ago by Jun Omae

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 5 years ago by Ryan J Ollos

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 4 years ago by Ryan J Ollos

Resolution: fixed
Status: assignedclosed

comment:12 in reply to:  9 ; Changed 21 months ago by Ryan J Ollos

Replying to 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.

I'm preparing the code for integration into Trac and trying to determine if this is still needed. Does it apply to all versions of Internet Explorer?

comment:13 in reply to:  12 Changed 21 months ago by Ryan J Ollos

Replying to rjollos:

Replying to 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.

I'm preparing the code for integration into Trac and trying to determine if this is still needed. Does it apply to all versions of Internet Explorer?

On closer look it appears that is only needed for supporting jQuery < 1.4.

Last edited 21 months ago by Ryan J Ollos (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.