I am having a problem with JQM where an external page’s working code inside an internal page would not load.
Here is the code for the external page (works fine on its own):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="en" />
<link href="jquery.zrssfeed.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript"></script>
<script src="jquery.zrssfeed.min.js" type="text/javascript"></script>
<title>zRSSFeed - Basic RSS Feed Example</title>
</head>
<body>
<h1>zRSSFeed - Basic RSS Feed Example</h1>
<p>Simple as it gets, this example uses the same code as in the documentation.</p>
<script type="text/javascript">
$(document).ready(function () {
$('#test').rssfeed('http://feeds.reuters.com/reuters/oddlyEnoughNews', {
limit: 5
});
});
</script>
<div id="test"></div>
</body>
</html>
Now…the problem is when I put that code into an internal page:
....<script src="jquery.zrssfeed.min.js" type="text/javascript"></script> //include in head...
<div data-role="page">
<div data-role="header">
<h1>Page Title</h1>
</div><!-- /header -->
<div data-role="content">
<p>Page content goes here.</p>
<script type="text/javascript">
$(document).ready(function () {
$('#test').rssfeed('http://feeds.reuters.com/reuters/oddlyEnoughNews', {
limit: 5
});
});
</script>
<div id="test"></div>
</div><!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
Is there any extra requirments to get this to work?
For some reason the feed does not appear at all in the internal page.
Solution
When you are using AJAX to load the pages, then it seems like only referenced pages (
<div data-role="page"> ... </div>) are loaded and not the complete website, this way the script doesn’t get excuted.You need to include your script to load in the page-div not in the head, to get the conde on page load.
Your start/landing page
Page to load
What gets loaded (via AJAX)