73887

Question:
I have the following page,
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" href="<%= ResolveUrl("~/css/jquery.mobile-1.3.0.min.css") %>" />
</head>
<body>
<form id="form1" runat="server">
<div>
<div data-role="page" id="newsDeatils">
<div data-role="content">
<h3 id="newsTitle"></h3>
<p id="newsCategory">
<div id="newsDescription"></div>
</div>
</div>
</div>
</form>
<script src="<%= ResolveUrl("~/js/jquery.min.js") %>"></script>
<script>
$(document).bind("mobileinit", function () {
$.mobile.autoInitializePage = false;
});
</script>
<script src="<%= ResolveUrl("~/js/jquery.mobile-1.3.0.min.js") %>"></script>
<script src="<%= ResolveUrl("~/js/knockout-2.2.0.js") %>"></script>
<script src="<%= ResolveUrl("~/js/NewsDetails.js" )%>"></script>
<script>
$.mobile.initializePage();
</script>
</body>
</html>
NewsDetails.js will send an ajax request then fill the newsDescription div
with a table. But nothing is working?
Rather than delay initialising the whole page it would be better to allow it all to be initialised, then initialise just the new code. In jQm v1.3.2 and earlier you could do this by adding the following code to your success callback.
$('#newsDescription table').trigger('create');
This will allow the whole page to initialise and prevent a flash of an unstyled page to the user if they have a slow network connection which could cause your ajax request to take a while.
Answer2:I have put $.mobile.initializePage();
inside success callback every thing works then.