WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Need to add jquery accordion to navigation (19 posts)

  1. meganlee1984
    Member
    Posted 3 years ago #

    I'm trying to add a dynamic page accordion and I don't think I am targeting my selectors correctly. This is my code:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    and my site: http://www.svadsi.info.

    Thanks in advance for any help

  2. Rafael Sirotheau
    Member
    Posted 3 years ago #

    instead of #content ul.menu, try div.menu-top-menu-container ul#menu-top-menu

  3. meganlee1984
    Member
    Posted 3 years ago #

    No, this does not work either. Thank you though.

  4. Rafael Sirotheau
    Member
    Posted 3 years ago #

    the problem is the way your using. console show this error: $ is not a function.. WordPress has a protection to avoid script conflicts (or something like that)...

    There's two away to override this. First and easier (but not always work) is by changing the $(document).ready(function() to jQuery(document).ready(function($).

    Second, you can keep the original code, and substitute all $ to jQuery. So it'll look like this.
    [Code moderated as per the Forum Rules. Please use the pastebin]

  5. meganlee1984
    Member
    Posted 3 years ago #

    Hi Thank you so much for your response. This is a step better, but now the children pages are not showing while the parent page is active:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  6. Rafael Sirotheau
    Member
    Posted 3 years ago #

    try this

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I've just changed the ... li.current-menu-item ul ... to ... li.current-menu-parent ul ...

    Also, if you want to have the accordion effect on click, You must remove the link from the parent menu title, or every click will load a page and you won't see the effect

  7. meganlee1984
    Member
    Posted 3 years ago #

    Still, its not working. It seems like its almost there. Thank you again for all of your help

  8. Rafael Sirotheau
    Member
    Posted 3 years ago #

    that's because you're using jquery instead of jQuery on your code (like jquery(document).ready...). try it

  9. meganlee1984
    Member
    Posted 3 years ago #

    I'm getting the error that jquery is not defined

    also, I'm calling to jquery via the wordpress
    <?php wp_enqueue_script('jquery'); ?>

    maybe if that gives you more insight.

    Thanks again

  10. meganlee1984
    Member
    Posted 3 years ago #

    I've tried both jquery and Jquery

  11. Rafael Sirotheau
    Member
    Posted 3 years ago #

    it's capital Q not J, and this correction is in your script code, not the wordpress jquery call function

  12. meganlee1984
    Member
    Posted 3 years ago #

    AHH, I mean I tried jquery and jQuery.

  13. Rafael Sirotheau
    Member
    Posted 3 years ago #

    I think I've found the problem. try this

    [Code moderated as per the Forum Rules. Please use the pastebin]

  14. meganlee1984
    Member
    Posted 3 years ago #

    YES!!!! This works.

    Thank you for all of your help

  15. Rafael Sirotheau
    Member
    Posted 3 years ago #

    no problem... that's the meaning of community.. =)

    if you still have question or need help for other projects, feel free to contact me on gtalk rsirotheau [at] gmail [dot] com

    and please mark this topic as solved (top right menu)

  16. waaab
    Member
    Posted 2 years ago #

    I'm hoping you still check this post....

    how can I set the accordion menu to display my pages too, not only my subpages?

  17. Rafael Sirotheau
    Member
    Posted 2 years ago #

    If you can, supply your code or site address, so I can take a look...

    I explain a bit more your problem, please.. =)

  18. waaab
    Member
    Posted 2 years ago #

    Thanks for your reply.

    It is actually about WordPress - Accordion Menu plugin!

    here is the link: Accordion Menu

    the plugin's accordion-menu.js:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Thank you in advance

Topic Closed

This topic has been closed to new replies.

About this Topic