Link to home
Start Free TrialLog in
Avatar of Crazy Horse
Crazy HorseFlag for South Africa

asked on

Code not working in Firefox but works in other browsers

I am using a third party theme for an admin/dashboard area and everything works fine except in Firefox. When I try to perform a particular action I get this error in console:


unreachable code after return statement

This is the code it seems to be complaining about...



   
         handleDropPosition: function() {
                return;
                
                if (dropdown.options.dropAuto == true) {
                    if (Plugin.isInVerticalViewport() === false) {
                        if (dropdown.currentDropPos == 'up') {
                            element.removeClass('m-dropdown--up');
                            dropdown.arrow.prependTo(dropdown.wrapper);
                            dropdown.currentDropPos = 'down';
                        } else if (dropdown.currentDropPos == 'down') {
                            element.addClass('m-dropdown--up');
                            dropdown.arrow.appendTo(dropdown.wrapper);
                            dropdown.currentDropPos = 'up'; 
                        }
                    }
                }
            },

Open in new window

Avatar of Dr. Klahn
Dr. Klahn

Firefox blocks pop-ups and drop-downs as the default configuration.  This may be what you are running into.
That warning message means that there is a non-conditional return statement before the end of the function. In this case, it's the first statement, so the function will return immediately without doing anything.

Earlier this week, I put a non-conditional return statement in the middle of a function while debugging and Firefox gave me the message too.
That error message is common with many 3rd party tracking codes but on my sites it doesn't stop the javascript on the page from working.  Is there something that actually isn't working?
Avatar of Crazy Horse

ASKER

Dave, yes. There is something that doesn't work. I have my own jQuery code which is meant to hide an element when a link is clicked. It works 100% in Google Chrome but not Firefox. My client refuses to use Chrome and wants me to fix it for Firefox but I actually don't know how. This is my code but Firefox isn't showing this as the issue:

	$( '#add-more' ).on('click', function() {
		var branch = 	"<div class='form-group m-form__group' id='branch'>" +
						"<label for='example_input_full_name'>" +
						"Branch/Outlet " + "<a href='' id='removeBranch'>Remove</a>" +
						"</label>" +
						"<textarea class='form-control m-input' name='branch[]' rows='6'></textarea>" +
						"</div>";
		$( '.more' ).prepend(branch);
	});

	$( 'body' ).on('click', '#removeBranch', function(e) {
		e.preventDefault();
		$(this).closest(branch).remove();
	});

Open in new window

I think those may be two separate issues.  I don't use jquery very much so someone else will have to answer that part.
ASKER CERTIFIED SOLUTION
Avatar of Snarf0001
Snarf0001
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Awesome, thanks.