I’m implementing a jquery mobile site and I’ve hit a snag when trying to show a count of RSS feeds using class="ui-li-count"
I’m able to pull the number from my script but it will not alert or display in the class="ui-li-count" unless I alert a string first.
For example:
The span I am trying to add my count to – <span id="rsscount" class="ui-li-count"></span>
Code that neither alerts or displays the count:
<script>
$(document).ready(function () {
alert(feedcount);
$('#rsscount').html(feedcount);
});
</script>
Code that both alerts the number and properly display the count inside my span after I dismiss the alert:
<script>
$(document).ready(function () {
alert("3");
$('#rsscount').html(feedcount);
});
</script>
I am using ZrssFeed to get the feed. Any idea what that alert string does to make this work?
feedcountappears to be undefinedYou are probably defining it in response to some Ajax event firing.
document.readyalmost certainly fires before the HTTP request to trigger that event comes back.Move the call to
html()to the callback for the Ajax request.