</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2012-08-27 23:12:19Z" class="relativetime">7 years ago</span>.</div>
</div>
</aside>
Possible Duplicate:
jQuery Mobile styles for an asynchronously included div
Jquery mobile listview - check initialization is complete
I have a mobile jquery list view and there is a LOAD MORE BUTTON at the end. Everything works fine except that the css is missing on the new results added using AJAX.
Here is my Button code
<div data-role="fieldcontain">
<a onclick="loadmore(this);" type="button" id="showmore" href="#more">Load more..</a>
</div>
Javascript
function loadmore(a) {
jq("#show_more_btn").removeClass("show_more_btn");
jq("#show_more_btn").addClass("loading_btn");
jq("this").css("display", "none");
if (null == jq.cookie("bp-activity-oldestpage")) jq.cookie("bp-activity-oldestpage", 1, {
path: "/"
});
var b = jq.cookie("bp-activity-oldestpage") * 1 + 1;
jq.post(ajaxurl, {
action: "activity_get_older_updates",
cookie: encodeURIComponent(document.cookie),
page: b
}, function (a) {
jq("#show_more_btn").removeClass("loading_btn");
jq("#show_more_btn").addClass("show_more_btn");
jq.cookie("bp-activity-oldestpage", b, {
path: "/"
});
jq("li[class='load-more']").hide();
jq("#activity-stream").append(a.contents);
}, "json");
return false
}
Screenshot of correct listview http://s12.postimage.org/yd2hsk119/original.jpg
Problem http://s17.postimage.org/81ofaf1bz/got.jpg
EDIT: Listview code
<div class="content-primary">
<ul data-role="listview" id="activity-stream">
<?php endif; ?>
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<?php locate_template( array( 'activity/entry.php' ), true, false ); ?>
<?php endwhile; ?>
<?php if ( empty( $_POST['page'] ) ) : ?>
</ul>
</div>
Entry.php
<li id="activity-<?php bp_activity_id(); ?>">
<a href...>...</a>
<h3>...</h3>
<p>...</p>
</li>
Anyone knows what the problem is ?
</div>
You need to refresh the listview
like this:
$("ul").listview('refresh');
You are adding the elements to the list but they are not styled by jQuery mobile since they do not have the proper classes and attributes.