Provide example of content loaded via Ajax instead of page redirect
Opened this issue · 10 comments
I'm working on top of Admin-starter-tomcat project.
I'm using "sidebar-menu tree" on the left, but I don't want it collapse when click on submenu link.
Same problem is in admin-showcase demo, If you click Ui Element-> Accordion and then UIElement ->AutoComplete , you can see UiElement close and open again. Maybe all sidemenu is reloaded.
It's possible to leave expanded submenu when click same submenu items ?
- AdminFaces version: 4.0.0
- PrimeFaces version: 7.0
- JSF implementation:
Hi, can you take a screenshot to make sure we're talking about the same thing? Thanks
Well there is a page reload, that's why it refreshes. This is needed because you're navigating to a different page. If you stay on the same page and reload content via ajax (imitating a SPA), the menu will not refresh
I thought only "content" div change when new page is selected. There is a way in admin-template to change only "content" div ?
yea but keep in mind that this is not a admin-template thing but how the web works.
You can reload the content div via ajax when you click on menu link instead of redirecting user to a new page but you'll need to take care of other things like the page url, how to bookmark pages, JSF viewScoped beans ( viewScope beans are alive as long the page doesn't change), you'll need to save the state somewhere to know what to render in content div, handle the browser back button and so on, probably there is a dozen of other problems to take care.
So I prefer to keep things simple and just redirect user to a new page which has its own JSF managed bean and it works pretty great.
PS: Some (5) years ago I did that (content reload via ajax) in an old framework I maintained using JSF, you still can see the example here where the pageControl panel is updated via ajax and statelessPersonMBean.beanState
decides which pages (find, list, update, friends) will be rendered.
I know how works SPA, I thought admin-template works as SPA, like AdminLTE.
Here you can see how AdminLTE left menu works :
https://adminlte.io/themes/AdminLTE/
again, the template doesn't enforce it, it just turns out that we don't have examples where the content is loaded via ajax.
ok, thank you.
Maybe in future you can post some examples or an "admin-starter-ajax" project that works like AdminLTE using ajax ?
👍
thank you