Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

TypeError: this.$firstLink is null

Home Forums Older releases 0.9.x TypeError: this.$firstLink is null

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1337
    sau_152mm
    Participant

    please help.
    getting this error – TypeError: this.$firstLink is null -line 345,(” return this.$firstLink.css(‘display’) == ‘block’;”).
    I use such a structure:
    if ($(window).width()<990){
    $('#drop-menu').smartmenus();
    } else {
    $('#drop-menu').smartmenus('destroy');
    }.
    For desktop I do not need smartmenus()?

    #1616
    sau_152mm
    Participant

    this condition and I put resize on the windows.initially no error. there is an error in resize window.

    #1617
    sau_152mm
    Participant

    found another bug, when you click on the button “menu+” falls smartmenu, try to close the menu opened when one of the items and then re-open does not work is the principle “accordion”.

    #1618
    admin
    Keymaster

    Hi,

    About the first issue – I guess you call this on window resize so you can avoid the JS error (which is harmless, btw) by using a short timeout for the destroy call – i.e. instead of:

    $('#drop-menu').smartmenus('destroy');

    use this:

    setTimeout(function() { $('#drop-menu').smartmenus('destroy'); }, 1);

    Because on destroy the script unbinds its own resize handler but still it gets called for the same resize event. It’s a bit tricky to explain but anyway, just use the timeout if the JS error bothers you.

    About the second “bug” – it’s not a bug, this is how it works by default. You can read this thread for more info and ways to customize the behavior:

    http://www.smartmenus.org/forums/topic/submenu-is-open-indicator

    Cheers!

    #1619
    sau_152mm
    Participant

    thank you very much for your help (a pleasure to deal with a smart man), about bug did not quite understand but try to understand

    #2315
    max
    Participant

    I was fooling around with the “var jq = $.noConflict” stuff, which I might need to come back to in another post.

    But got the error

    
    'this.$firstLink' is null or not an object in Line 3: jquery.smartmenu.min.js
    

    Would I also use a timeout vice destroy and where would this be. I do see a “destroy” call in jquery.smartmenus.min.js

    but don’t know if this is what you referring to in this post.

    Thank You,

    Max

    #2316
    max
    Participant

    I redid this with jquery.smartmenus.js and I got the following error:

    ‘this.$firstLink’ is null or not an object

    jquery.smartmenus.js Line: 336

    Lines

    335: isCssOn: Function() {
    return this.$firstLink.css(‘display’) == ‘block’
    },

    Note, I’m going to redo this post and ask in a separate post.

    Thank You,

    Max

    #2317
    max
    Participant

    I should also mention that prior to the error on line 336 I got the Explorer 8.0.6 error:

    Line: 584
    Object required jquery.smartmenus.js

    which in my version of smart menus (0.93) is as follows starting at line 574

    
    574: menuInit: function($ul) {
      75:    if (!ul.dataS('in-mega')) {
      76:       this.subMenus.push($ul);
      77:       // mark UL's in mega drop downs (if any) so we can neglect them
      78:       if ($ul.hasClass('mega-menu')) {
      79:          $ul.find('ul').dataSM('in-mega',true);
      80:       }
      81:      // get level (much faster than, for example, using parentsUtil)
      82:      var level = 2,
      83:            par = $ul[0];
    584:      while ((par = par.parentNode.parentNode) != this.$root[0]) {
      85:         level++;
      86:      }
    
    #2322
    admin
    Keymaster

    Hi,

    The problem @sau_152mm had was caused by additional custom code he had added on the page. So it shouldn’t be related to your issue although you get a similar error message. I suspect in your case you simply need to make sure your menu HTML structure is valid – e.g. make sure opened <li> tags are closed properly, all tags are properly nested, etc.

    If you can’t cope on your own, please post an URL to some kind of live demo and I will check it at first chance.

    Cheers!

    #2325
    max
    Participant

    Dear Admin: I spent hours on the debugger to fix my problem. Finally, I started searching for a better jquery-based drop down menu system.

    I COULD NOT FIND one as nice as yours. But I was going to switch.

    you were right. My problem was so simple.

    here’s the code I had wrong:

    
    <li><a>ITC/context_tile.jsf?menu=show>Slide Show</a>
       <ul>
           <li><a href="#">Manage slide show</a></li>
               <ul>
                    <li><a href="stuff">...</a></li>
              </ul>
          </li>
       </ul>
    </li>
    

    I add an extra <li>.

    I would of never guessed the problem was so simple. Ended up that IE processed the menu find. Firefox did not.

    Thank you so much. I’m glad to be back in the “SmartMenu” fold.

    #2326
    max
    Participant

    Oops, the post cut out part of my text.

    I said my problem was that I had an extra

    <listed item> but when I put “l” and “i” inside brackets it disappears. see end of last post.

    So the error

    
    'this.$firstLink' is null
    

    is caused by simple incorrect html syntax.

    #2328
    admin
    Keymaster

    Glad to hear you’ve fixed the issue! Yep, this is a quite common problem actually since it’s quite easy to mess up the structure if you don’t pay attention. And when it’s not valid all kinds of troubles might arise.

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