0

I need to change the url from my twig template, when I click in different buttons, whithout a refresh. Is it possible?

I need it because I am having the following problem: if my url is .../project/User/Groups and I click on 'friends' tab (it is a paragraph element with a onclick action), I want the url to be .../project/User/Friends, because all the information is already on the page, and I only hide/show it, but I need the url to change because in the main html.twig template I have a 'info' div in which I show different messages, and, for instance, if I need to show a message from 'friends' tab (the info is on a friends html.twig) and in the url I have .../project/User/Groups, it is not shown.

The parameter in the url after /User/ is used to know which tab has to be selected when I load the page from other urls in my project.

I hope I have explained correctly.

1 Answer 1

1

You can't change url without page refresh.

What you can do (and this is way how it is supposed to be done) is adding some extra stuff to your url after # character. See gmail's #inbox for instance.

You can do it by using some javascript window.location.hash = 'inbox'. However there are several js libraries for manipulating hashes in url, for example sammy

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.