我有一个JSON它看起来像
[
{
"sid": "1",
"webform_views_add_sublocation_form_tour_name": "4",
"webform_views_add_sublocation_form_location": "location1",
"webform_views_add_sublocation_form_sub_location": "sublocation1"
},
{
"sid": "2",
"webform_views_add_sublocation_form_tour_name": "4",
"webform_views_add_sublocation_form_location": "location2",
"webform_views_add_sublocation_form_sub_location": "sublocation1"
},
{
"sid": "3",
"webform_views_add_sublocation_form_tour_name": "4",
"webform_views_add_sublocation_form_location": "location1",
"webform_views_add_sublocation_form_sub_location": "sublocation2"
},
{
"sid": "4",
"webform_views_add_sublocation_form_tour_name": "4",
"webform_views_add_sublocation_form_location": "location1",
"webform_views_add_sublocation_form_sub_location": "sublocation3"
},
{
"sid": "5",
"webform_views_add_sublocation_form_tour_name": "4",
"webform_views_add_sublocation_form_location": "location2",
"webform_views_add_sublocation_form_sub_location": "sublocation2"
},
{
"sid": "8",
"webform_views_add_sublocation_form_tour_name": "4",
"webform_views_add_sublocation_form_location": "location1",
"webform_views_add_sublocation_form_sub_location": "sublocation4"
},
{
"sid": "10",
"webform_views_add_sublocation_form_tour_name": "6",
"webform_views_add_sublocation_form_location": "location2",
"webform_views_add_sublocation_form_sub_location": "sublocation3"
}]
我想这个JSON作为colapsible集位置加载到段部分和sublocation是内容的一部分。
$(document).on('pageshow','#locations' ,function(event, ui){
var tourid = $.urlParam('tourid');
$('#location-list').empty();
$.getJSON('url', function(data) {
$.each(data,function(i,row){
if(tourid == row.webform_submissions_webform_views_add_sublocation_form__webf){
$('#location-list').append('<div data-role="collapsible"><h3>'+row.webform_submissions_webform_views_add_sublocation_form__webf_1+'</h3><ul data-role="listview"><li><a href="#">'+row.webform_submissions_webform_views_add_sublocation_form__webf_2+'</a></li></ul></div>');
$('#location-list').collapsibleset('refresh');
}
});
});
});
我喜欢输出
location1
---sublocation1
location2
---sublocation1
location1
---sublocation2
location1
---sublocation3
location2
---sublocation2
但我需要这样的
location1
--sublocation1
--sublocation2
--sublocation2
location2
--sublocation1
--sublocation2
到jQuery Mobile的可压缩集我怎么能这样做