3
I’m developing a system using PHP
, with the idea of owning only one page. How? (I do not know if it is the best solution, I believe it is not) , I developed a side menu that is fixed and the contents to be changed would be in the center of the page, the side menu contains some "links"ex:
<li class="treeview">
<a id="menuPerfil">
<i class="fa fa-user"></i>
<span>Perfil</span>
</a>
</li>
By clicking on this "link", I upload a file html
which contains a simple form according to the clicked menu link.
I made a script
jQuery
using the function load()
:
$("#menuPerfil").click(function () {
$('#principalContent').load("formPerfil.html.twig");
});
As links are clicked, a certain link is loaded html
. But the html
loaded by the load function jQuery
cannot access something that is on the index, for example a tag
of twig
, It’s like carrying a html
independent of the index, and not only include it.
I wonder if anyone knows a way to solve using the function .load()
, bearing in mind that it does not accumulate the files html
loaded on the same page, or some other way to properly load this data, without having to make a different page for each system functionality.
NOTE: I use PHP
, twig
and jQuery
in the project.
Hiago, I tried to use what you suggested and it didn’t work for me, and it inserts the code into html every time I click on a menu (possible to view in Chrome F12). Thanks for your help
– mauricio caserta
ah, it’s reloading the page? it’s a link right... missing a false Return in the function . click the id #menuPerfil is already in your DOM or is it added via javascript? I will edit the answer so you can do but one test.
– Hiago Souza