Simplest way to NOT Hide a form??

Hi Folks

I use the onHide event to trigger some validation code and force the user to cancel or save certain changes. When the code runs on a simple tab form - that is when the user moves from one tab form to another tab in the same form, the code drops back to the form with the changes to save or cancel.

However if the user selects a form (using a menu selection) that is in another tab form or a parent tab form, the onHide does not drop back to the form with changes, instead displays the save or cancel dialog (mine) and then remains on the newly selected form.

Perhaps the form context could help here but the wiki is rather cryptic on how that might be used in a multi-tab scenario as we have here, but it looks like overkill to keep the same form open in this situation?

Q. How can I prevent the changed form from being hidden?

Hi Ian,

By returning false in the onHide event you prevent a form from being hidden (in a dialog this means the dialog won’t close).
Just use a global JS variable (a variable that is defined without a ‘var’ in front of it) or even a form variable and trap for it in the onhide like so:

function formHasChanges() {
    myGlobalonHideLock = true;
}

function formRelease() {
    myGlobalonHideLock = null;
}

function onHide() {
    if (myGlobalonHideLock) {
        return false; // block closing the dialog
    }
    return true;
}

Hope this helps.

I think the problem is that the form is not in a dialog Robert. I guess I could stop it closing if it were.

I do return false to the onHide event Robert - and when I’m in a simple tab form, preventing hiding one form in the tab it works as expected.

But say we have this structure:

Parent - Tab1Form_a
Children Tabs - Tab2Form_a
Tab2Form_b
Tab2Form_c
Tab2Form_d

If I use onHide on say Tab2Form_b then attempt to select Tab2Form_c, form Tab2Form_b is prevented from hiding.
However if I select Tab1Form_a then Tab2Form_b is hidden immediately . My trapping code is run and the warning dialog is shown to save or cancel (its shown over the Tab1Form_a form BTW).

Is this a bug or am I doing something wrong.

Cheers Robert - great support as always.

Hi Ian,

If all your forms are in tabpanels you could attach a method on the onTabChange event and handle things there.

Hope this helps.

so you are saying if you nest tabs and the deepest child tab says false if you hide a parent tab then it will still hide it?

try to create a simple sample and make case with it.