Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Menu problems

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #148610

    hello I have new menu just making.

    But my javascript does not pick up the new menu that have made.

    can figure out how to change it so can pick up the columns.

     $('#menu ul > li > a + div').each(function(index, element) {
          // IE6 & IE7 Fixes
          if ($.browser.msie && ($.browser.version == 7 || $.browser.version == 6)) {
             var category = $(element).find('a');
             var columns = $(element).find('ul').length;
    
             $(element).css('width', (columns * 143) + 'px');
             $(element).find('ul').css('float', 'left');
          }      
    
          var menu = $('#menu').offset();
          var dropdown = $(this).parent().offset();
    
          i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth());
    
          if (i > 0) {
             $(this).css('margin-left', '-' + (i + 5) + 'px');
          }
       });
    
    <?php if ($categories) { ?>
    <div class="container">
      <div class="row">
        <nav class="navbar navbar-default" role="navigation">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-categories">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
    
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse nav-categories">
          <ul class="nav navbar-nav">
            <?php foreach ($categories as $category) { ?>
            <?php if ($category['children']) { ?>
            <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?><span class="caret"></span></a>
            <ul class="dropdown-menu">
            <?php for ($i = 0; $i < count($category['children']);$i++) { ?>
            <?php if (isset($category['children'][$i])) { ?>
            <li>
            <a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a>
            </li>
            <?php } ?>
            <?php } ?>
            </ul>
            </li>
            <?php }else{ ?>
            <li>
            <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
            </li>
            <?php } ?>
            <?php } ?>
            </ul>
          </div><!-- /.navbar-collapse -->
        </nav>
      </div>
    </div>
    <?php } ?>
    
    #148873
    Chromawoods
    Participant

    Where is that JS located, I assume it is not just floating above the HTML like that? Is it even inside a <script> tag? Included somewhere? When is the JS executed, could it be executing before the HTML exists?

    #148907

    no js is is in different location I am having now my programmer look at it.

    #148926
    Ed
    Participant

    It looks like the problem might be an overly specific jQuery selector that’s missing your elements.

    See if it works if you remove + div from the selector. If that doesn’t fix it, try changing it to #menu ul li.

    It would be good if you could provide us with an example (a live page that demonstrates the problem) so we can debug it and fix it for you!

    #149118

    I am just working on new one now. just also got beta version of this store I have working on it now

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.