0

I am trying to develop a mobile site using jQuery mobile and ASP.NET MVC 3. I have a simple login view as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="@Links.Content.Site_css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />

    <script src="@Links.Scripts.jquery_1_5_1_min_js" type="text/javascript"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.js"></script>
</head>

<body>
    <div data-role="page">
        <div data-role="header">
            <h1>Login</h1>
        </div>
        <div data-role="content">
           @using (Html.BeginForm())
{ 

<div data-role="fieldcontain">
    <label for="username">Username:</label>
    <input type="text" name="username" id="username" value="" />
</div>
<div data-role="fieldcontain">
    <label for="password">Password:</label>
    <input type="password" name="password" id="password" value="" />
</div>

<div data-role="fieldcontain">
    <fieldset data-role="controlgroup">
        <legend></legend>
        <input type="checkbox" name="rememberMe" id="rememberMe" class="custom" />
        <label for="rememberMe">Remember Me</label>
    </fieldset>
</div>

<input type="submit" value="Login" data-theme="e" />

}
            </div>
        <div data-role="footer">
                          </div>
    </div>

</body>
</html>

Below is the code for my controller:

public partial class AccountController : Controller
    {
        [HttpGet]
        public virtual ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        public virtual ActionResult Login(string username, string password)
        {
            return MVC.Admin.Home.Index();
        }
    }

When the login button is clicked I just want to redirect the user to the home screen. But for some reason I get the following error:

Microsoft JScript runtime error: Unable to get value of the property '_trigger': object is null or undefined Line Number 2371: to.data( "page" )._trigger( "beforeshow", null, { prevPage: from || $("") } );

Can anyone help me with this issue?

1 Answer 1

1

You must include the div with tag [data-role="page"] on your page

<div data-role="page" data-theme="b"></div>
Sign up to request clarification or add additional context in comments.

Comments

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.