问题
am trying to populate a list view via ajax and jquery. after i have populated the data. the enhancement doesnt show.
this is what i did. Fiddle Result
var poss_ans = "6,4,8,2";
var possibleAnswers = poss_ans.split(","); //poss_ans is string containing all the answer from the database
$(document).on("pagecreate", "#page1", function () {
var $posans = $('#poss_ans');
for (var i = 0; i < possibleAnswers.length; i++) {
var label = possibleAnswers[i];
$radio = $('<li />', {
id: 'rad' + i,
text: possibleAnswers[i],
});
var $label = ' <li ><a href="#" class="rem"> <h2>Dynamic</h2><p><b>To Peter Griffin</b><p>Ah, Mr. Griffin, Im not quite sure how to say this. Kim Bassinger? Bass singer? Bassinger?</p></a></li>';
$posans.append($label);
}
$posans.enhanceWithin().closest("fieldset").controlgroup("refresh");
});
now in the result pane(inside my fiddle) are two different results. the first result labeled " Static".is what i want to acheive when i receive the data. and the second to the last one is what am getting instead. when i inspect the element in the browser there is a new class(ui-link) that is been added to the . i tried to remove it but its not working.
i dont know why the enhanceWithin() is not working. could some please help me out.
回答1:
Just change the last line to
$posans.listview("refresh");
API DOC: http://api.jquerymobile.com/listview/#method-refresh
Updated FIDDLE
来源:https://stackoverflow.com/questions/30218192/enhancewithin-is-not-working