javascript

I have two webpage in my project, the first one is the login page and the second is the user page, in which I have a control that wraps a javascript library that handles the main menu.
When the user presses the exit button, the application launches this function:
/ / Close all webpages
for i as integer = Session.PageCount-1 downto 0
Session.PageAtIndex (s). Close
next

/ / And move to a fresh login page
LoginPage.show

Everything works fine except the main menu which continues to appear on the login page.
What should I do to close it before login page will displayed again ?

So, I mean “I have to restart my application as if it were the first time.”

Thanks in advances

Luciano

What is your Main Menu object and how did you get it to appear?

I created a wrapper for the control javascript library (Metromenu) based on the jQuery library.
And I called the function that creates the menu inside the event SetupJavascriptFramework:

LoadLibraries(MakeConstructor,“http://xxxxxxxx/portale/CloudCross/metromenu5/js/jquery-1.9.0.min.js","http://xxxxxxxx/portale/CloudCross/metromenu5/js/MetroMenu.js”)

Where in the function MakeConstructor there is the javascript function code to execute:

$. MetroMenu (
{
backicon: “static / img / back.png”, / / Sub menu item back
animation: “fadeInLeft”, / / Animation
position: “bottom”, / / Position
withtooltip: true, / / Show tooltip on mouse over
closeonclick: false, / / Menu item click, close the menu
escclose: true, / / ESC key, close the menu
items: [
{Name: “Comments”,
ago: “fa-comments-but-2x”
},
{Name: “Comment”,
ago: “fa-comment-or-2x ago”
}]
}
);

and I have set :
ShowInTrayArea = true

ah okay. I bet the MetroMenu class has a method to hide it (or close it).

Hello greg,
I solved the problem, there was a function to call:

CloseMetroMenu ();

but now I have a 'other problem, when i login the second time, the second webpage with the menu reappear, but when I click on the options menu nothing happens!
As if he did not longer the callback from the browser!
This is the callback function that I’ve appended to the main function “$. MetroMenu …”

“function (OptionPress) {Xojo.triggerServerEvent (’” + Self.ControlID + “’, ‘OptionPress’, [OptionPress])”) "

So, the event is executed only the first time!!

This is the complete javascript code, that I put in LoadLibraries function :

$.MetroMenu({
backfa: “fa-arrow-left fa-2x”,
backlabel: “Indietro”,
animation: “fadeInLeftBig”,
color1: “#ff7f00”,
color2: “#e57200”,
position: “top”,
withtooltip: true,
closeonclick: false,
escclose: false,
items:[{ name: “Home”,
fa: “fa-home fa-2x”},
{ name: “Email”,
fa: “fa-envelope fa-2x”},
{ name: " "},
{ name: “Azioni”,
fa: “fa-tasks fa-2x”,
items:[{ name: “Consegnata”,
fa: “fa-check fa-2x”},
{ name: “Agenzia chiusa”,
fa: “fa-lock fa-2x”},
{ name: “Rifiuta”,
fa: “fa-exclamation-triangle fa-2x”},
{ name: “Collo mancante”,
fa: “fa-question fa-2x”},
{ name: " ", }]},
{ name: " "},
{ name: “Info”,
fa: “fa-info fa-2x”},
{ name: “Settings”,
fa: “fa-cogs fa-2x”},
{ name: " "},
{ name: “Uscita”,
fa: “fa-sign-out fa-2x”}, ],
},
function(OptionPress) { Xojo.triggerServerEvent(‘XKtPCmbJ’,‘OptionPress’, [OptionPress] ) });

Luciano,

You could just reload your session like this:

ShowURL( "https://" + Session.Header("Host") )

Thanks Jay, Works like a charm! Many thanks!

yeah, I suspect that after you called the Close method, the callbacks were destroyed. You would have needed to hook them back up again when the user entered the app again.

Thanks Greg.