Display only certain list items in listview with javascript -


i have made listview of jquery mobile , it's displaying 4 list items. list generated javascript.

$( document ).ready(function() { var data = [{         "name": "lichtbediening",         "category": "category",         "info": "klik voor lichtbediening",         "img": "lichtbediening" }, {         "name": "stopcontact",         "category": "category",         "info": "klik voor stopcontacten",         "img": "stopcontacten" }, {         "name": "enkele schakelaar",         "info": "een knop, een lamp",         "img": "rolluikbediening"        }, {         "name": "dubbele schakelaar",         "info": "twee knoppen, twee lampen",         "img": "multimedia"      }];  var output = ''; $.each(data, function (index, value) {     output += '<li><a href="#">'     output += '<img src="img/' + value.img + '.jpg">'     output += '<h2>' + value.name +'</h2>'     output += '<p>' + value.info + '</p>'     output += '</a></li>'; });  $('#list_zoek_category').html(output).listview("refresh");  }); 

at moment displays "each" row in data list item in list. want display listitems category == category.

does have idea how can make work?

do below

$.each(data, function (index, value) {     if(value.category != 'category')         return;  // if value.category not equal 'category` nothing, exit.     output += '<li><a href="#">'     output += '<img src="img/' + value.img + '.jpg">'     output += '<h2>' + value.name +'</h2>'     output += '<p>' + value.info + '</p>'     output += '</a></li>'; }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -