1

I'm using jQuery Mobile on an MVC 3 website. Working well except that I have an tag that links to a controller action that returns a RedirectResult. It looks like jQuery is intercepting the link and it errors out every time. I get the standard "An error has occurred" message that the mobile framework outputs. Inspecting the response with Firebug shows the response is totally empty.

I've heard there might be a data- attribute I need to add to the tag to make the mobile UI ignore it? Any ideas on that or other solutions?

EDIT: Just for clarification, the URL is being generated correctly and is a valid URL, it has something to do with the way jQUery mobile is intercepting the request.

<a href='/[email protected]["URL"]' title="view full site" >view full site</a>

public RedirectResult FullSite()
                {
                    StringBuilder redirectUrl = new StringBuilder("http://www.site.com/");

                    try
                    {
                        string referringUrl = Request.QueryString["p"];

                        if (!String.IsNullOrEmpty(referringUrl) && referringUrl.Contains("photo-gallery"))
                            referringUrl = referringUrl.Replace(@"/photo-gallery", String.Empty);

                        redirectUrl.Append(referringUrl);
                    }
                    catch (Exception)
                    {
                        redirectUrl.Clear();
                        redirectUrl.Append("http://www.site.com");
                    }

                    CookieManager.SetMobileToFullSiteCookie();
                    return new RedirectResult(redirectUrl.ToString());
                }

1 Answer 1

2

I use rel="external" to force links to load as a normal request instead of using AJAX.

<a href='/fullsite?pRequest.ServerVariables["URL"]'
   rel="external"
   title="view full site" >view full site</a>

You can also use data-ajax="false" or set a value for target, see the docs for 1.0a3 at http://jquerymobile.com/demos/1.0a3/docs/pages/link-formats.html

Sign up to request clarification or add additional context in comments.

2 Comments

I think I like data-ajax better. Seems more jQuery mobile-ish. :)
@Scott, for an actual internal link that you want to simply reload afresh, I agree. My use case is actually an external link and rel="external" is more semantically correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.