0

$.mobile.loadPage('view-video'); is not working, and i have sample code bellow. Please help me to resolve this issue.

I am getting the Alert "Function Triggered"

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>

<div data-role="page" id="index">
  <div data-role="header">
    <h1>Welcome To My Homepage</h1>
  </div>

  <div data-role="main" class="ui-content">
    <p>I Am Now A Mobile Developer!!</p>
    <a href="javascript:void(0)" class="loadVideo">Load Video</a>
  </div>

  <div data-role="footer">
    <h1>Footer Text</h1>
  </div>
</div> 

<div data-role="page" id="view-video">
  <div data-role="main" class="ui-content">
    Your Video Will be Here.
  </div>
</div> 

<script type="text/javascript">
    $(document).on('click', '.loadVideo', function(e){
        alert('Function Triggered');
        $.mobile.loadPage('view-video');
    });
</script>
</body>
</html>
Michael
  • 189
  • 1
  • 17
rkaartikeyan
  • 1,977
  • 9
  • 29
  • 57

1 Answers1

1

First the documentation says

Note: jQuery.mobile.loadPage is deprecated as of jQuery Mobile 1.4.0 and will be removed in 1.5.0. Use the pagecontainer widget's load() method instead.

Got it working in this Fiddle with JavaScript. Instead of $(':mobile-pagecontainer').pagecontainer('load', "view-video); it have to be $(':mobile-pagecontainer').pagecontainer('change', "#view-video");! (change instead of load and with # cause it's an id)

See jQuery Mobile Demos for detail instructions. Important is that each page has it data-role="page" attribute => jQuery Mobile Tutorial

Michael
  • 189
  • 1
  • 17