JQuery Mobile 1.1.0 RC1 HREF Change for AJAX Messages in Safari iOS

Disclaimer: I am using jQuery Mobile 1.1.0 RC1, which is not yet stable. I have a link that should send an AJAX request and return a JSON response, but when I click the link, it seems that jQuery Mobile changes HREF to hash (#) in iOS Safari on iPhone. This is not done when testing in browsers with iPhone User Agents. Here is my basic HTML and JS to show what I have:

<a href="/link/to/ajaxpost/">Send Ajax Request</a>

and js

$('#tab a').on('click', function(e){
        var $this = $(this);
        var jsonUrl = $this.attr("href");
        alert(jsonUrl);

        $.mobile.showPageLoadingMsg();

        $.ajax({
            type: "POST",
            url: jsonUrl,
            success: function(data) {
                $.mobile.hidePageLoadingMsg();
                alert(data);
            }
        });
        return false; 
});

"jsonUrl" "#" ( url ajax), , JSON, . , iOS Safari iPhone. , JSON , jQuery Mobile OSX Safari Firefox.

rel= "external" data-type = "ajax" , . jQuery Mobile 1.1.0 RC1, , , jQuery Mobile . JQuery Mobile JS , , , -, . .

+5
1

:

$this.attr('href')

:

$this.data('href') || $this.attr('href')

jQuery Mobile 1.1.0RC1 ( 1.1.0) href # href data-href, ., . iOS Mobile Safari.

, github, JQuery UJS Ruby on Rails :

http://scottwb.com/blog/2012/06/29/jquery-mobile-breaks-your-hrefs-on-ios-mobile-safari/

+2

All Articles