2012-01-03 4 views
0

JSON에 의해 ​​생성 된 listview가 있지만 모든 목록 항목 요소를 포함하도록 div 태그를 동적으로 만드는 방법을 알지 못합니다. CSS 형식이없는 목록처럼 보입니다. 내가 뭘 잘못하고 있는지 모르겠다. 이것은 문제 페이지입니다. http://mbeta.calvaryccm.com/#teachings 이것은 다음과 같이 표현하고자합니다 : http://mbeta.calvaryccm.com/ 필자는 필자가 필요로하는 것을 보여주기 위해리스트 뷰의 형식을 지정하는 방법을 모르겠습니다.jQuery Mobile JSON 형식화

답변

3

당신이, 당신이 초기화하거나 목록보기 새로 고침해야합니다 (아약스를 통해) 동적 콘텐츠를 추가하는 경우 :

$('#mylist').listview(); 
// or if you already have a listview that you are appending to 
$('#mylist').listview('refresh'); 

가에서 Calling the listview plugin 참조 페이지 하단

+0

효과가 있습니다. 도와 줘서 고마워! –

0

글쎄, 나는 여기에 전체 코드를 작성할 수 없습니다하지만 난이 같은 것을 쓸 필요가 되리라 확신합니다 ". ATTR (

// i assume your JSON response is stored in data object 
// following is the loop which reads the data object ,gets the value and append it to the `<li>` of `<ul>` 

var에 목록 = $ (")를 "ID를", " 명부"); // JQuery와 동적으로 새로운 UL 요소를 만들

for(var i=0;i<data.length;i++) 
{ 

var li=$("<li/>").html(data[i].name); // get the value of name in JSON and put it in newly created li ,(getting value will depend on your json string format) 

$("#list").append(li); //append li to ul of id list 

} 

$(body).append(list); // append the list to anywhere you want, i am appending it to body.