TypeError: this.$firstLink is null
Home › Forums › Older releases › 0.9.x › TypeError: this.$firstLink is null
- This topic has 11 replies, 3 voices, and was last updated 5 years, 12 months ago by
admin.
-
AuthorPosts
-
April 5, 2014 at 14:52 #1337
sau_152mm
Participantplease 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()?April 5, 2014 at 15:01 #1616sau_152mm
Participantthis condition and I put resize on the windows.initially no error. there is an error in resize window.
April 6, 2014 at 23:28 #1617sau_152mm
Participantfound 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”.
April 7, 2014 at 06:27 #1618admin
KeymasterHi,
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!
April 8, 2014 at 02:11 #1619sau_152mm
Participantthank you very much for your help (a pleasure to deal with a smart man), about bug did not quite understand but try to understand
March 10, 2015 at 22:13 #2315max
ParticipantI 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
March 11, 2015 at 02:07 #2316max
ParticipantI 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
March 11, 2015 at 02:38 #2317max
ParticipantI 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.jswhich 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: }
March 12, 2015 at 17:20 #2322admin
KeymasterHi,
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!
March 13, 2015 at 01:55 #2325max
ParticipantDear 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.
March 13, 2015 at 02:00 #2326max
ParticipantOops, 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.
March 13, 2015 at 10:36 #2328admin
KeymasterGlad 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.
-
AuthorPosts
- You must be logged in to reply to this topic.