Reputation: 1
I have to append data in template in jquery mobile through ajax call and I am using following libraries and listview function to referesh the existing with listview("refresh") function but it shows js error i.e. listview is not a function while function is present in below libraries:
<script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script>
<script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script src="https://d10ajoocuyu32n.cloudfront.net/codiqa.ext.js"></script>
here is what I have used
jQuery(document).ready(function () {
jQuery('.pagination_ajax_request').click(function () {
jQuery.ajax({
type: 'POST',
url: this.href,
dataType: 'html',
data: 'pagination_ajax_request=1',
success: function (response) {
// check if <div id="pagination"><div> exist, means ajax resopnse from post listing page other wise ajax resopnse from topic listing page
if (jQuery("#pagination").length) {
jQuery("#pagination").append(response);
} else {
jQuery("#topic_list").append(response);
jQuery("#topic_list").listview("refresh");
}
if (ajax_pagination_data['current_page'] != ajax_pagination_data['total_pages'] && ajax_pagination_data['current_page'] != '0') {
//update "Load More Topics" OR "Load More Posts" link href value
var href = jQuery(".pagination_ajax_request").attr('href');
jQuery(".pagination_ajax_request").attr('href', href.replace(/&?trail=\d+/, '&trail=' + ajax_pagination_data['trail']));
} else {
//hide "Load More Topics" OR "Load More Posts" if No topic OR post
jQuery(".pagination_ajax_request").hide();
}
},
error: function (xhr, textStatus, errorThrown) {
alert('An error occurred while processing your request.\n' + textStatus + ': ' + errorThrown);
}
});
return false;
});
});
Upvotes: 0
Views: 2405
Reputation: 1
I was having the same problem. I reverted back to jquery v1.8.3 and that fixed the issue.
You can try the combination of 1.8.3 and 1.3.1 here: http://jsfiddle.net/dPwzE/
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script
<script type="text/javascript" src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
Upvotes: 0
Reputation: 1117
what data you get from server is important here. and for add dynamic content in list view here is example
i think you miss some element or something while adding the li
$('<li>').append('<a href="#">Mercedes</a>').appendTo('#test-listview');
or you can try
var UI = $('#listViewID');
for(x in data){
UI.append(data);
}
$('#listViewID').listview("refresh");
Upvotes: 1