I need to disallow navigation away from unsaved changes based on the user's
response in an alert.

I have some application-wide strategies in mind, and I have also seen how I
can prevent tab switching in a tab navigator by registering a capture-phase
click listener and calling stopImmediatePropagation and preventDefault.

But the same strategy didn't work on a DataGrid, where the grid selection is
used as a form of navigation:

                <mx:DataGrid id="roleList"
                    creationComplete="onGridCreationComplete(event)"

            private function onGridCreationComplete(event:Event):void {
               myGrid.addEventListener(MouseEvent.CLICK, onClickGrid, true,
10);

            }
            private function onClickGrid(event:Event):void {
                // alert goes here
                event.stopImmediatePropagation();
                event.preventDefault();
            }

 As a workaround I could handle the change event and restore the previous
selection but it would  be better to conditionally suppress the selection.

I've seen the post on Alex's blog, but am hoping for something
listener-based. Thanks.

Reply via email to