Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Error thrown when activeBtnClass is set to an empty string #4811

Closed
tomvanenckevort opened this issue Aug 7, 2012 · 2 comments
Closed

Error thrown when activeBtnClass is set to an empty string #4811

tomvanenckevort opened this issue Aug 7, 2012 · 2 comments

Comments

@tomvanenckevort
Copy link

When overriding the activeBtnClass default setting with an empty string (if you wanted to have no special highlight class for active buttons), it throws an unhandled exception when closing dialogs.

So when you're initially loading jQuery Mobile, you override the activeBtnClass like this:

$.mobile.activeBtnClass = "";

When you then have a page that opens a dialog, clicking the close button of the dialog throws the following error:
Uncaught Error: Syntax error, unrecognized expression: .

It turns out that when executing the pagehide event handler it executes the following code (line 4158 in jQM1.1.1):

.bind( "pagehide", function( e, ui ) {
            self._isClosed = false;
            $( this ).find( "." + $.mobile.activeBtnClass )
                                     .not( ".ui-slider-bg" )
                                     .removeClass( $.mobile.activeBtnClass );
        })

Because activeBtnClass is an empty string, it tries to execute find(".") which is not allowed in jQuery, hence the exception.

To solve this there either needs to be a check whether activeBtnClass is empty before executing this code, or the documentation should specify that activeBtnClass cannot be an empty string.

As a workaround for now, if you wanted to have no active button state class, you could set activeBtnClass to a non-existent CSS class name.

@jaspermdegroot
Copy link
Contributor

@tomvanenckevort

Can you add a link to this ticket here https://github.com/jquery/jquery-mobile/wiki/Feature-Requests. Thanks!
Closing as a feature request.

@ghost
Copy link

ghost commented Apr 29, 2013

Hi, I just encountered this and it was only showing up for me with iOS 6.0 Safari. Other systems (chrome on windows, safari on mac, chrome on mac, firefox on win+mac, all android browsers) seemed to ignore the problem entirely. I was using jquery mobile 1.3.1 and jquery 2.0.0. Also, it would only show up when transitioning from one page to another with the loading gif attempting to find the nearest activeBtnClass object - I also have set ajaxEnabled=false. I don't really need to have the activeBtnClass set to empty, so it's no skin off my nose whether this is available or not, but I thought I would document what I found.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants