Page 1 of 1
Tab switcher
Posted: Wed Dec 15, 2010 7:45 am
by ursl40
Hy!
I have a tab switcher, with four different tabs, two of them are for user and car.
When I click (in my list of users) on selected user, it goes from there to tab swither - to tab user (for editting user). If I select tab car, car of that user comes up, and I can edit car (for editing car). But if I click button Save, it throws me back to tab user (all fields are empty) and if I after that again click on tab car, it says: Saved successfully...
Where is the problem? Thanks!
Re: Tab switcher
Posted: Wed Dec 15, 2010 7:54 am
by superdezign
Vague, but if it says "saved successfully," it's likely been saved successfully. You just have an issue in your code where the default tab is still set to your "user" tab after submitting your form. If your "tab switcher" uses a hash on your URL to define the currently opened tab, then you need to use that in your <form>'s action attribute. So, if to default to the car tab you go to
http://example.com/file.php#car, then change your action from "
http://example.com/file.php" to "
http://example.com/file.php#car".
Re: Tab switcher
Posted: Wed Dec 15, 2010 7:58 am
by ursl40
I don't know where the default tab is selected/written... I'm using this:
http://homework.nwsnet.de/products/e877_tab-switcher
Re: Tab switcher
Posted: Thu Dec 16, 2010 6:37 am
by ursl40
Anyone please?
Re: Tab switcher
Posted: Thu Dec 16, 2010 9:20 pm
by McInfo
In
tabswitcher.js, find
Code: Select all
// Display the first tab content.
this.show(this.targetIds[0]);
and replace it with
Code: Select all
// Get the hash from the URI.
var id = window.location.hash.split('#')[1];
if (id) {
// Display the requested tab content (if it exists).
this.show(id);
} else {
// Display the first tab content.
this.show(this.targetIds[0]);
}
This solution could cause all tab pages to disappear if the hash does not match an existing tab id. You might want to test that the requested id matches one of the elements in the aElems array rather than just testing that the hash exists as is done here.
Be sure to follow superdezign's advice of adding the appropriate hash to the form's action attribute.
Re: Tab switcher
Posted: Fri Dec 17, 2010 7:59 am
by superdezign
If McInfo's solution does cause issues, then find out how your tab switchers defines the active tab and submit the form with a query string in the action attribute instead of a hash. Then, use that to dynamically generate JavaScript code to define the active element.