Toggle jQuery effect of external page via require or PHP include


I'm creating a users menu, it is on a page that is incorporated into other pages such as index and home for example. It assumes the role of a widget that is only shown if there is a session (user logged in) but it is shown with jQuery's toggle effect to show and hide.

On the page of the script the toggle effect works normally, but on the pages it is displayed via include or require it expands and collapses automatically or opens and closes. How can I solve this, I already searched the API but without success I used "perventDefault()" also without success. Grateful for any help!


Your problem description "it automatically expands and collapses ie opens and closes" gives me the idea that you are loading the same code twice.

The first he gives the order to open and the second to close. Since this happens without interaction ie automatically when the page opens, I assume this is the problem.

Take a look at the rendered code and see if you have the script present more than once. If "yes" correct this, so as not to load the same script more than once.

Scroll to Top