icon for Daring Fireball's Markdown syntax

formatting via Markdown

to format your text, add images and links - you can now use the lovely Markdown syntax. The small editor icons will do half the work for you - but if you wish to explore other options ~ see this reference from Daring Fireball (John Gruber)
mobile menu javascript problem
  • nazimnazim
     
    April 2012
    For my client project I added an accordion menu for my menu div when viewing the site on a small screen. The following script is used to get this effect



    // show menu (smallest screens)
    $('#menu-toggle').click(function() {
    $('#menu ul').slideToggle('slow', function() {
    // Animation complete.
    });
    $('ul').addClass('view');
    });
    });


    However, recently my good friend Julio found out that the menu doesn't execute on all pages and if you want to enable it, the light box doesn't work and vise versa. As most of us are using Satellite 1.5 for our client project i found out that other java script can conflict with each script, so the mootool.js and slimbox.js conflict with the above script. On my own client site i found the recent.php, tag.php and tags.php the lightbox works fine but the accordion menu script doesn't work.

    Here is what i did to solve the problem, the first thing to do is to take the above script and make some minor changes.

    Below is the above script with the minor changes



    // show menu (smallest screens)
    var $j = jQuery.noConflict();
    // Use jQuery via $j(...)
    $j(document).ready(function(){
    $j('#menu-toggle').click(function() {
    $j('#menu ul').slideToggle('slow', function() {
    // Animation complete.
    });
    $j('ul').addClass('view');
    });
    });
    [Please note #menu-toggle is the name of my you might have a different one.]

    add the whole script before the . if you have the mootools.js and the slimbox.js script on the top of your html page take it down to the bottom before the . You should make the above changes in the following pages, recent.php, set.php, tag.php and tags.php (assuming you have these pages). These are the only pages that have more then one JavaScript.

    I hope it helps

    regards
    Nazim

    p.s here is were i found the solution to the problem, just in case the above method doesn't work for you
    http://api.jquery.com/jQuery.noConflict/
     
  • JulioJulio
     
    April 2012
    Nazim thank you very much, I will try that now. I try something similar but yours is much more complete. I'll tell you what happened.
    P / S: Try to see your page in multiple browsers, I think this does not work in Opera :-/.
     
  • priscaprisca
     
    April 2012
    Excellent write-up, Nazim ;)
    Well done for solving this problem!!
     
  • nazimnazim
     
    April 2012
    thank you, my pleasure.
     
  • JulioJulio
     
    April 2012
    Nazim you're my hero! thank you very much, you've just removed a major headache : D
    I tried it on multiple browsers and it works fine!
    thanks for sharing this info.
     
  • priscaprisca
     
    April 2012
    Sooooo nice to see you helping each other out and sharing all these solutions here!!! Makes me smile happily :-)

    Aw, you're all growing up so fast - into self-sufficient webbies :-)
     
  • priscaprisca
     
    May 2012
    Nazim ;)
    had to add that to my quick tips section, just for future reference:
    http://graphiceyedea.co.uk/11/jquery-clash/

    thanks again ;)
     

Welcome!

Feel free to join the discussions ~ sign in or apply for membership below.

Sign In with Twitter

In this Discussion

webeyedea forum:
part of the 'design for the web' course
but everyone is welcome ~ so join us ;)
quoting code snippets:
for best display of code - add it within these tags, specifying your quoted language.
for example:
<pre lang="html">
<!-- your HTML code here -->
</pre>
<pre lang="css">
/* your CSS code here */
</pre>