Handlerbar refresh list instead of append

This is the code I am using to append data -

schoolNews = $.parseJSON(JSON.stringify(data.data.posts));
$(".schoolNewsList").append (theTemplate(schoolNews)); 
$("#scroller ul").listview().listview('refresh');

Now what I want to do is refresh the whole list instead of appending data to it.


It looks as if you are using a control for the listview() functionality. I am not certain what that is and do not know how to interface with that. However, in looking at your code, I am seeing that you are calling the append() function, instead of the html(). Calling html() will replace all code inside of the element.

New Code:
schoolNews = $.parseJSON(JSON.stringify(data.data.posts));
$(".schoolNewsList").html (theTemplate(schoolNews));
// instead of appending the values, set the value of the html
$("#scroller ul").listview().listview('refresh');

I'd do:

schoolNews = data.data.posts;  //No need for encoding decoding
$(".schoolNewsList").html(theTemplate(schoolNews));   //Replace contents instead of appending
$("#scroller ul").listview().listview('refresh');


Need Your Help

Java tabbed panes within internal frame

java swing user-interface awt

I am trying to get an internal frame to contain tabbed panes. However, my code does not seem to be loading the panes into the internal frame. I have my code in the java files, called InternalFram...

Fetching current x-position when graph is set to scroll in iOS-Charts

ios swift ios-charts

I am using setVisibleXRangeMaximum(6) to set maximum x-value display, so that I display only 6 chart item at a time. When I scroll to the graph to and fro, is it possible to get the highest and least