Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2020-04-26 05:56 PM
Hello All,
I have implemented Jason Solar's Prev-Next tab code Toggle Tab Controls (previous,next), but I would like to save the record before the tab switcher runs. I can get the record to save, then switch tabs, but then the page reloads and it goes back to the default tab. I am guessing I need to learn how to use David Petty's suggested Windows sessionStorage Property, but I do not understand javascript enough to make those changes. Anyone that can help me would be greatly appreciated.
Ken
2020-04-27 05:09 AM
2020-04-27 12:54 PM
Normally Archer shouldn't be defaulting back to the default tab when saving a record. How are you calling the save?
Advisory Consultant
2020-04-27 01:04 PM
I tried two different ways, first in the script itself. This code is from @jason solar
<script type="text/javascript">
var tabIndexes, tabSetId, selectedTabIndex;
function pageLoad() {
$.each($LM._tabSets, function(key, value) {
tabSetId = key;
});
if (tabSetId) {
tabIndexes = $LM._tabSets[tabSetId].tabIds;
var tabStripElementId = 'master_DefaultContent_rts_ts' + tabSetId + '_t';
var tabStrip = $find(tabStripElementId);
selectedTabIndex = tabStrip._selectedIndex;
// Hide previous button if users is on the first tab
if (selectedTabIndex == 0) $('.btnprev').hide();
// Hide next button if users is on the last tab
if (selectedTabIndex == 3) $('.btnnext').hide();
}
}
function selectTab(action) {
var tabId, tab;
if (action == 'prev') {
$('#master_btnApply').click(); //Added by Ken to save record first
tabId = tabIndexes[selectedTabIndex-1];
tab = $('li.tab_'+tabId).find('a.rtsLink').trigger('click');
tab.find('span.rtsTxt').trigger('click');
}
if (action == 'next') {
$('#master_btnApply').click(); //Added by Ken to Save record first
tabId = tabIndexes[selectedTabIndex+1];
tab = $('li.tab_'+tabId).find('a.rtsLink').trigger('click');
tab.find('span.rtsTxt').trigger('click');
}
}
</script>
Then I tried it in the HTML, again this code came from Jason's solution.
<table border='0' style='width: 100%'>
<tr>
<td style='width: 50%; text-align:left; padding: 10px;'>
<img class="btnprev"
src="../BackgroundImageGenerator.axd?className=StyledButton&classProperties=caption:Previous+Module;iconSetStyle:VistaRound;baseColor:%23DDDDDD;disabled:False"
onclick="$('#master_btnApply').click();selectTab('prev')"
/>
</td>
<td style='width: 50%; text-align:right; padding: 10px;'>
<img class="btnnext" src="../BackgroundImageGenerator.axd?className=StyledButton&classProperties=caption:Next+Module;iconSetStyle:VistaRound;baseColor:%23DDDDDD;disabled:False"
onclick="$('#master_btnApply').click();selectTab('next')"
/>
</td>
</tr>
</table>
2020-04-27 03:10 PM
Thanks, the issue is that the save is "dumping" the page along with the next call selectTab. You'd need to store the the tab index before you save the page to recall it when the page loads.
Something like this:
<script type="text/javascript">
var tabIndexes, tabSetId, selectedTabIndex, tabStripElementId, tabStrip;
Sys.Application.add_load(function() {
$.each($LM._tabSets, function(key, value) {
tabSetId = key;
});
if (tabSetId) {
tabIndexes = $LM._tabSets[tabSetId].tabIds;
tabStripElementId = 'master_DefaultContent_rts_ts' + tabSetId + '_t';
tabStrip = $find(tabStripElementId);
selectedTabIndex = tabStrip._selectedIndex;
// Hide previous button if users is on the first tab
if (selectedTabIndex == 0) $('.btnprev').hide();
// Hide next button if users is on the last tab
if (selectedTabIndex == 3) $('.btnnext').hide();
}
if (sessionStorage["tabIndex"]) {
tabStrip.get_tabs().getTab(sessionStorage.getItem("tabIndex")).click();
sessionStorage.removeItem("tabIndex");
}
});
function selectTab(action) {
var tabId, tab;
if (action == 'prev') {
sessionStorage.setItem("tabIndex", tabIndexes[selectedTabIndex-1]);
$('#master_btnApply').click(); //Added by Ken to save record first
//tabId = tabIndexes[selectedTabIndex-1];
//tab = $('li.tab_'+tabId).find('a.rtsLink').trigger('click');
//tab.find('span.rtsTxt').trigger('click');
}
if (action == 'next') {
sessionStorage.setItem("tabIndex", tabIndexes[selectedTabIndex+1]);
$('#master_btnApply').click(); //Added by Ken to Save record first
//tabId = tabIndexes[selectedTabIndex+1];
//tab = $('li.tab_'+tabId).find('a.rtsLink').trigger('click');
//tab.find('span.rtsTxt').trigger('click');
}
}
</script>
Advisory Consultant
2020-04-27 03:14 PM
Thank you David Petty and Ilya Khen I had to move on to something else, but I will test this out and post the results.
Ken
2020-04-27 03:16 PM
I finally figured out this mention thing. Thanks go out to Jason Solar for the code snippet he originally shared.
2020-04-27 05:55 PM
I'm getting an error on the page shown in the screen cap.
2020-04-28 03:24 AM
Sys.Application.add_load does not require function declaration. Also, you need to write it as:
Sys.Application.add_load(function() {
});
2020-04-28 08:54 AM
My bad, copying and pasting
I've updated my post with the correction.
Advisory Consultant