B4J Question BANano - Load additional Layout

Declan

Well-Known Member
Licensed User
Longtime User
I am running the awesome BANano Library by @alwaysbusy.
I have a SKNavigationBar in my layout ("main")
When the user clicks on an option of the SKNavigationBar, I need to load a new layout ("contact")

I have tried:
B4X:
Sub SKNavigationBar1_Click (event As BANanoEvent, menu As String)
If menu ="contact" Then
        Log("Clicked on CONTACT")
        BANano.LoadLayout("#body", "contact")
    End If
End Sub
Where "contact" is my Layout

I receive the following error in the Log:
B4X:
app.js:9 Uncaught TypeError: Cannot read property 'addmenu' of undefined
    at banano_cc.banano_ready (app.js:9)
    at app.js:9
 

alwaysbusy

Expert
Licensed User
Longtime User
The navigation bar is probably in your layout itself, no? If so, replacing that layout with another layout will kill the previous menu, hence giving this error.
You will need an outer layout containing the SKNavigationBar that is loaded on the #body. In this layout you can use a SKContainer.

Now every time you want to load a layout, load it in this SKContainer.

Check out the WebsiteDemo in the zip, it uses multiple layouts where a user can navigate by the menu.

The BaseLayout contains the SKNavigationBar and the SKContainer1. All other layouts are loaded on the SKContainer1 control, depending on what one has clicked in the menu.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
I have run the Demo "ChatNoir" WithRouter.
The text does not show in SKNavigationBar1.
I get the following error:
B4X:
Access to XMLHttpRequest at 'file:///C:/PROGRA~2/ANYWHE~1/B4J/LIBRAR~1/BANano4.50c/BANano4.50/WEBSIT~1/WITHRO~1/Objects/ChatNoir/assets/en.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
app1587984847755.js:2 Network error
assets/en.json:1 Failed to load resource: net::ERR_FAILED
index.html:1 Access to XMLHttpRequest at 'file:///C:/PROGRA~2/ANYWHE~1/B4J/LIBRAR~1/BANano4.50c/BANano4.50/WEBSIT~1/WITHRO~1/Objects/ChatNoir/assets/en.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
app1587984847755.js:2 Network error
app1587984847755.js:2 GET file:///C:/PROGRA~2/ANYWHE~1/B4J/LIBRAR~1/BANano4.50c/BANano4.50/WEBSIT~1/WITHRO~1/Objects/ChatNoir/assets/en.json net::ERR_FAILED
dohttpforurl @ app1587984847755.js:2
loadlanguagefile @ app1587984847755.js:2
sknavigationbar1_click @ app1587984847755.js:2
(anonymous) @ app1587984847755.js:2
n.handleclick @ app1587984847755.js:2
(anonymous) @ app1587984847755.js:2
(anonymous) @ app1587984847755.js:2
a @ app1587984847755.js:2

I there a very simple code example that will show only a couple of options on a SKNavigationBar that will load additional layouts?
I could then build on this.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
I finally have WithoutRouter running.
Thanks for your patience.
I have put so much into this already, I must continue.
Your demo is awesome, but very much an overkill for my app - basically an input for a MySQL database with Labels and Textboxes.
I will try to edit the WithoutRouter demo to "remove" the loading of texts from json files.
Do you feel that this is the correct "learning-curve" I should pursue?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
I wouldn't take the WebsiteDemo as a base, as it was a real project I made for a friend, but is only a Website (static, no input possible). You can use it to to find out how to load multiple layouts however.

I would start from scratch.
1. First design your layouts in the abstract designer
2. Generate the events on buttons, inputs, etc...
3. Write the logic of your app

Have you decided what to use for your backend? (php, or a B4J server). If you would use B4J, \BANano4.50\B4JServerDemo\New System 4.50+\Demo in the zip is a good starting template as it demonstrates how both the frontend and backend talk to each other.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
I have, earlier today, started from scratch but had a problem loading layouts from the SKNavigationBar.
In VS I just used a Tab control.
I will use B4J Server as I am somewhat familiar with it.
I have a B4J UI app that I have written that writes/reads data to/from a MySQL database.
I was hoping to reconfigure into a web app, but that has proven to be more difficult than I imagined.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
A need a couple of more days to finish the next version of BANano (with the new skeleton library that contains the tab control).

It have been long hours since the covid-19 thing (some people in the company in my day job have been set on non-active) and I have been covering a lot of work from them doing 18+ hour days. So apologies for my reaction to your 'switch back to c#' a couple of posts back ?

I'll send you a copy of the new version when I got something ready.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
No problem - same here, after the lock-down I was also dumped with work that others have ignored. Seems like a lot of people have resorted to being on holiday.
If I can get a small app going that will load 2 layouts from the SKNavigationBar I will be good to go.
Hopefully I will be able to connect directly to MySQL.
Many thanks for all your patience and assistance.
KEEP SAFE
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…