Skip to content


Exception in $.mobile.focusPage function with native iPhone #5029

quanta42 opened this Issue · 6 comments

5 participants



when I load my app with Cordova 1.7.0 with jqm 1.2.0-rc1 and jq 1.8.1, I have an issue during the initialization and each time I use $.mobile.changePage("#name_of_the_hash").
Here is the jsbin link to a simple test page:

I just copied/paste that in an html file, added cordova.js and run this example through iphone simulator 5 and 6 and I got Error: SYNTAX_ERR: DOM Exception 12.

Luckily for you, I was able to see what line cause the problem: line 3245 (jqm 1.2.0-rc1).
More precisely, the exception happens when this line is executed: pageTitle = page.find( ".ui-title:eq(0)" );

If I do a page.find(".ui-title"), it returns an empty array.



I'm seeing this with jqm 1.3.1 and jQuery 1.9.1, running in iPhone simulator. Both titles seem to exist.

I found out that you can get rid of the error by changing from

$.mobile.focusPage = function ( page ) {
        var autofocus = page.find( "[autofocus]" ),
            pageTitle = page.find( ".ui-title:eq(0)" ); this

$.mobile.focusPage = function ( page ) {
    var autofocus = page.find( "[autofocus]" ),
        pageTitle = page.find( ".ui-title" ).first();

oops... I commented the same thing on 6019... sorry... Good fix!


@quanta42 I can't tell based on these comments. Is this issue fixed?


@ldeluca I cannot reproduce this issue using jqm 1.4.4 and jq 2.1.1


Mind closing it out if you think it is fixed @quanta42?

jQuery Foundation member

Im going to close this as fixed.

@arschmitz arschmitz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.