Disabling Ajax in jQueryMobile

I am trying to use JQueryMobile for POC, and it seems like I'm using @using (Html.BeginForm ()) instead of @using (Ajax.BeginForm ()), ajax is enabled by default. It is entered from one of the script files [~ / Scripts / jquery.mobile-1.0a2.js].

So I want to just disable Ajax for certain forms and make full form posts. It can be pretty unpleasant, but I just tilt my head.

Any help is appreciated.

/ BB

+3
source share
5 answers

You must correctly configure the jquery framework to disable its auto-ajax

Here it is documented:

http://jquerymobile.com/demos/1.0a3/#docs/api/globalconfig.html

+4
source

You can do something like this.

<html lang="en-us">
<head>
    <title>@ViewBag.Title</title>
    <link href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.min.js")" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
        $(document).bind("mobileinit", function () {
            $.mobile.ajaxFormsEnabled = @ViewBag.EnableAjax;
        });
    </script>

    <script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js" type="text/javascript"></script>
</head>
<body>
    <div data-role="page" data-cache="never">
        <div data-role="header">
            <h1>@ViewBag.HeaderString</h1>
        </div>
        <div data-role="content">
            @RenderBody()
        </div>
        <div data-role="footer">
            <h1>HTDE</h1>
        </div>
    </div>
</body>
</html>
+4

, , document.Ready():

$.mobile.ajaxEnabled = false;
+4
0

Source: https://habr.com/ru/post/1794055/


All Articles