This is a migrated thread and some comments may be shown as answers.

active tab changes (not page) after client side event cancelled

2 Answers 131 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Adam King
Top achievements
Rank 1
Adam King asked on 08 Jan 2014, 04:13 PM
We are seeing the active tab change after onBeforeUnload client side event (clicking cancel to prevent postback) then clicking to save (causing postback)

We are adding a client side event [window.onbeforeunload] to handle the user exiting before saving. This will prompt the user to [OK or Cancel to lose changes] when they click away when editing. Testing this if we click on another tab it will prompt us and then we cancel. So far this works correctly. We stay on the same screen and tab and are still in edit mode. But when I click save it will save but then the active tab changes, it gets highlighted. The tab switched to is the one we click to initiate the ok/cancel. So it is as if the active/tab was stored around the time onBeforeUnload fired, then changed when it posted back.

Events.
1. On tab Go into edit mode which assigns  window.onbeforeunload event handler
2. Try to click into the second top level tab
3. we see the handler popup with ok/cancel to move and possible lose changes
4. click Cancel so don't move. Everything looks ok now.
5. Click save on the same page/tab which removes the event handler and posts back to save
6. We stay on the same page but the active tab changes to the second top level tab. We stay on the same page but its just the high-lighted tab that appears wrong.

I'm wondering if some radTabStrip events fire before window.OnBeforeUnload that save the active tab, even though we cancel (choose not to move) it will set that new tab on the next post back ?. Maybe there is a different event (prior to onBeforeUnload) that I must capture before the active-tab is changed.

On postback I may be able to check that the active tab matches the page and change the active tab but I'd prefer a cleaner solution.

2 Answers, 1 is accepted

Sort by
0
Adam King
Top achievements
Rank 1
answered on 09 Jan 2014, 11:45 PM
This is also happening in another instance which should be easy to recreate

1. Disable the normal tab navigation ( e.Tab.NavigateUrl = String.Empty;)
2. click tab (this causes a postback to the same page)
3. The active tab has automatically changed to the one clicked -- and the navigation does not occur (so active tab != active page)

Maybe this is what is expected but I would expect the tab to become active only if we move there.
This is more of a problem in the first post than this instance, because the first instance we're hitting the unload event which I would expect to run before the tab loads or even hits tab-click.
The preference is that the event (unload) runs before the new tab/screen attempts to load.
0
Nencho
Telerik team
answered on 13 Jan 2014, 11:18 AM
Hello Adam,

Regarding the issue, described in your first post - I would like to ask you to submit a support ticket, attaching a runnable sample, where the issue is replicable. Thus we would be able to inspect it locally and provide you with the proper solution. As for the issue, described in your second post, would you specify which event are you using the set the e.Tab.NavigateUrl property? I had performed some tests locally, but I was unable to replicate the described problematic behavior.

Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
TabStrip
Asked by
Adam King
Top achievements
Rank 1
Answers by
Adam King
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or