jQuery external page Toggle effect via require or include PHP

Asked

Viewed 129 times

3

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

On the script page the toggle effect works normally bad on the pages it displays via include or require it expands and automatically collects or opens and closes. As I can solve this, I have already searched in the API but without success I have already used "perventDefault()" also without success. Grateful for any help!

  • You are adding the same script twice?

  • No intendi? I call the page with require or include if there is session...so I only call once

  • 1

    My duvica is if in the final code there will be 2x the same script. I ask to try to mislead what might be the problem

  • I do the check with a simple "if(!isset)"...about the code and the javascript calls on the index there is only the ajax Cdn while in the code there is tbm will be that? I’m gonna see...

  • 1

    Yes @Sergio was this...two calls, at index and at home (among others) I have to call the CDN ajax and in the script tbm...ai I had to leave the menu on display None and a click event for toggle. It worked, thanks for the help :)

  • You’re welcome. You want to delete the question or I’ll leave you an answer?

  • 1

    If you want to leave a reply I thank (and favorite) maybe help other tbm

Show 2 more comments

1 answer

1


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

The first he gives the order to open and the second to close. Since this happens without interaction or 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" fix this, do not load the same script more than once.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.