2014-05-25 1 views
0

나는 해결책을 찾기 위해 인터넷을 샅샅이 찾았지만 나에게는 효과가 없었습니다.JQuery 모바일 스타일은 .load()에서 html 콘텐츠로 유지되지 않습니다.

JQuery Mobile + PHP와 Phonegap을 사용하여 하이브리드 모바일 앱을 만들고 있습니다. 동적 내용을 삽입하려고하면 JQuery Mobile 스타일이 반환 된 HTML 내용에 적용되지 않습니다. 정적 컨텐츠를 테스트

위해 - PHP/홈 - 바 -리스트 friends.php :

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8"> 
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user- scalable=0;" name="viewport" /> 
<meta name="apple-mobile-web-app-capable" content="yes" /> 
<title>Barslide</title> 

<link rel="stylesheet" href="themes/Barslide-swatches.min.css" /> 
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" /> 
<link rel="stylesheet" href="themes/main.css" /> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile.structure-1.4.2.min.css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script> 

<script> 
$(document).on('pageinit', "#home", function() { 
$("#home-bar-list-friends").load("php/home-bar-list-friends.php"); 
$("#home-bar-list-friends").listview("refresh"); 

}); 
</script> 

</head> 
<body> 

...

<ul id="home-bar-list-friends" data-role="listview" data-inset="true" data-theme="b"> 
</ul> 

PHP 스크립트 : 여기

내가 함께 일하고 있어요 무엇인가
<?php 
echo 
' 
    <li><a href="bar.html?id=100">101 Cantina | 11</a></li> 
    <li><a href="bar.html?id=101">Grogg House | 9</a></li> 
    <li><a href="bar.html?id=102">Tall Pauls | 7</a></li> 
    <li><a href="bar.html?id=103">08 Seconds | 4</a></li> 
    <li><a href="bar.html?id=104" rel="external">The Swamp | 2</a></li> 
</ul>'; 
?> 
+0

alert()와 같은 다른 명령도 실행되지 않습니다. – Zach

답변

0

해결했습니다. 나는 창조 사건을 포함시키지 않았다.

$(document).on('pagebeforeshow', '#bars', function(){ 
$('#bars-list').empty(); 
$.post('php/bars-list.php',function(bars) 
{ 
    $('#bars-list').append(bars); 
    $('#bars-list').trigger('create'); 
    $('#bars-list').listview('refresh'); 
}) 
}); 
관련 문제