NetTalk Central

Author Topic: PWA/Disconnectd app and tabs  (Read 4854 times)

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
PWA/Disconnectd app and tabs
« on: March 20, 2019, 04:52:08 PM »
     My main form has three tabs.  If I select one, say tab 3, click on Save, Cancel or Close (X in upper right) I return to the browse.  If I select another row in the browse and click Change to edit the record, the form opens on the last selected tab, in this case tab 3.
     To remedy this I added some JavaScript to my custom js file:

$(document).ready(function() {
   
   $("[type=button]").on("click", function() {
   $("div#tab_updatecoincollection_div").tabs({active: 0, selected: 0, cache: false});
   });

})

     This works well when I select the Save or Cancel buttons, but does not work when I click Close button (X in upper right of form).  I'm not sure what the difference is with the Close button in the upper right.  The key is I want the form to always open on tab 1 (in this case tab 0, since tabs are zero based.)  Any thoughts on how to get the form to always open on tab 1?

Thanks,

Jeff King
« Last Edit: March 20, 2019, 04:57:55 PM by jking »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: PWA/Disconnectd app and tabs
« Reply #1 on: March 22, 2019, 01:25:04 AM »
Here's a better approach;

In your form procedure, right click on source, search for ntForm routine.
Scroll down to the onformOpen settings.

  loc:BuildOptions.free(true)
  loc:BuildOptions.Append('$("#updatecustomer_browseinvoice_div").ntbrowsels("refresh");')
  If loc:BuildOptions.Length()
    p_web.SetOption(loc:options,'onFormOpen','^function(action){{'&loc:BuildOptions.GetValue()&'}')
  End


Then in the embed point add to the function.

  loc:BuildOptions.free(true)
  loc:BuildOptions.Append('$("#updatecustomer_browseinvoice_div").ntbrowsels("refresh");')
  loc:BuildOptions.Append('$("#tab_updatecustomer_div").tabs("option","active",0);')
  If loc:BuildOptions.Length()
    p_web.SetOption(loc:options,'onFormOpen','^function(action){{'&loc:BuildOptions.GetValue()&'}')
  End


This function is called when the form is opened, so anything you want to do "whenever the form is opened" should go in here.
This is better than trying to trap "when the form is closed".

cheers
Bruce


jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: PWA/Disconnectd app and tabs
« Reply #2 on: March 22, 2019, 06:59:32 AM »
Bruce,

     Thank you!  That worked perfectly.

Jeff