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

Pages with data-ajax="false" on form fail to load #3472

Closed
dak opened this issue Jan 23, 2012 · 6 comments
Closed

Pages with data-ajax="false" on form fail to load #3472

dak opened this issue Jan 23, 2012 · 6 comments

Comments

@dak
Copy link

dak commented Jan 23, 2012

This seems to be a regression with Issue #1580.

A page will not load if it contains a form that has @data-ajax="false".

The original issue:
In the $.ajax() callback, we look for elements with @href, @src, and @data-ajax="false" elements, the code then assumes that matching elements will have either @href or @src, which of course forms don't ... they have @action ... so the code throws an exception because thisUrl is undefined.

I can confirm that adding @href to the form with @data-ajax="false" fixes the problem.

Original fix landed at:
e597ccb

@ghost ghost assigned johnbender Jan 23, 2012
@johnbender
Copy link
Contributor

@dak1

I can't reproduce, can you correct this jsbin to help me get something I can test against/debug?

http://jsbin.com/ayisul/3

Thanks for logging this issue!

@dak
Copy link
Author

dak commented Jan 24, 2012

I've been unable to reproduce this bug outside of PhoneGap (I've only tested it with PhoneGap 1.3 for iOS on XCode 4). The bug existed for both jQuery Mobile 1.0 and the latest nightly build as of today.

To reproduce the bug, create 2 html files (one page and one to be called as a dialog). The dialog page should have a form with @data-ajax="false". The bug does not seem to exist if the dialog is loaded using a hash on the same page.

Here are the two html files I am using, stripped down:

<title></title>
    <link rel="stylesheet" href="../css/jquery.mobile.css" />

    <script src="../phonegap-1.3.0.js"></script>
    <script>

        function onBodyLoad()
        {       
            document.addEventListener("deviceready", onDeviceReady, false);
        }

        function onDeviceReady()
        {
            // do your thing!
        }
    </script>

    <script src="../javascript/jquery.js"></script>
    <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.js"></script>
</head>
<body onload="onBodyLoad()">
    <div data-role="page" id="index">

        <div data-role="content">
            <a href="dialogs/create-account.html" data-role="button" data-rel="dialog">Test</a>
        </div><!-- /content -->

    </div><!-- /page: index -->
</body>

and the second file:

<title></title>
        <div data-role="content">
            <form method="post" data-ajax="false">
            </form>
        </div>

    </div>
</body>

I'm using jQuery Mobile 1.0 (as well as the nightly build - both don't work), and jQuery 1.6.4 in the above examples. Adding @href="#" to the form tag or removing @data-ajax="false" fixes the problem. "Fails to load" means that the ajax-loading.png is placed over the first page, although it is not animated and nothing happens.

The relevant error that comes up in the console upon clicking the button is:
jquery.mobile-1.0.js:2824TypeError: 'undefined' is not an object (evaluating 'thisUrl.replace')

Hope this helped. Let me know if you still have trouble reproducing it.

Derek

John Bender 2012/1/23 U6:36 gDG

@dak1

I can't reproduce, can you correct this jsbin to help me get something I can test against/debug?

http://jsbin.com/ayisul/3

Thanks for logging this issue!


Reply to this email directly or view it on GitHub:
#3472 (comment)

@toddparker
Copy link
Contributor

@dak1 - Can you provide a test URL for us to review these pages that uses latest instead of 1.0? If you toss the app mode meta tag into your pages, I wonder if we can reproduce by saving the pages to the iOS homescreen. Template using latest refs here: http://jsbin.com/agewuy/edit

@dcarrith
Copy link
Contributor

This type of issue also happens if you erroneously added the @data-ajax attribute to a button. :| The page with the button will fail to load. I created an issue a while back with the title "thisUrl is undefined Line 2998 of jquery.mobile-1.1.0-rc.1.js" #3677

With @jblas' help, I figured out that it was the @data-ajax attribute on the submit button that was causing the error.

Since no one else seems to be able to reproduce this with forms (me included since I already know it works because I have some forms with the @data-ajax attribute) I'm wondering if dak1's submit button (or any other button on the page) has a @data-ajax attribute.

@dak
Copy link
Author

dak commented May 20, 2012

I re-wrote the project that I was seeing this error in without using jQM (for unrelated reasons). I'll try to find some time tomorrow to pull up the old code and try to provide a test URL for this issue. I suppose it's possible I had a @data-ajax attribute on a button, although I don't believe I did.

@johnbender
Copy link
Contributor

@dak1

Closing as stale. Please re-open if this is still a problem.

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

4 participants