Keep navbar staticly available with Spring+Thymleaf
Keep navbar staticly available with Spring+Thymleaf
I am currently developing a WebApp with Spring-Boot and Thymeleaf.
The frontend uses HTML ofc, plain JS and a bit JQuery.
I wonder what is the best approach to keep the navbar staticly present when clicking on a button that results in getting a newly rendered HTML presentation with baiscally the same navbar by Thymeleaf?
My idea so far was to use AJAX after a button click that would result in a newly rendered page (jQuery load), store it temporarily, fade out the old content without the navbar und fadein the new content without the navbar too.
The tech should be the same! I know with Angular/SPA I wouldn't face this problem.
1 Answer
1
I think it's not difficult to implement.
You just need to use ajax request and return the view (content center,right html) and use jquery to load content from new html.
@RequestMapping("yourrequest")
public String viewName()return "any";//view name contain all html which you want to return (it might be jsp, thymeleaf, freemarker...)
At front end side:
$("#yourArea").html(newHtml);
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.