2011-01-28 4 views
0

현재 jQuery Mobile "pagebeforecreate"페이지 초기화 이벤트를 사용하여 HTML 페이지에 컨텐츠를로드하고 있습니다. jQuery Mobile 이벤트는 여기에서 설명합니다 : http://jquerymobile.com/demos/1.0a2/#docs/api/events.html. 컨텐츠가 동 기적으로로드되고 본문에 추가 된 후 jQuery Mobile이 페이지를 포맷합니다. 여기 jQuery Mobile - 브라우저가 jQuery 모바일 이벤트를 지원하는지 확인하는 방법

는 jQuery를 모바일 지원하는 브라우저에서 '내 코드입니다 :

<!DOCTYPE html> 
<html> 
<head> 
    <title>jQuery Mobile Test</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.4.4.min.js"></script> 

    <script> 
    $('body').live('pagebeforecreate',function(event){ 

     var ajaxContent = ""; 

     $.ajax({ 
      async: false, 
      type: "GET", 
      url: "test.xml", 
      dataType: "xml", 
      success: function(xml) { 

       $(xml).find('item').each(function() 
       { 
        ajaxContent += '<li><a href="'+$(this).find('link').text()+'">'+$(this).find('title').text()+'</a></li>'; 
       }); 
       //alert(ajaxContent); 
       $('#menu').append(ajaxContent); 
      } 
     }); 
    }); 
    </script> 

    <script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script> 
</head> 
<body> 
<noscript>You must have JavaScript enabled to view the content on this website.</noscript> 
<div data-role="page"> 

    <div data-role="header"> 
     <h1>jQuery Mobile</h1> 
    </div> 

    <div data-role="content"> 

     <ul data-role="listview" id="menu"> 

      <li><a href="#">Static</a></li> 

     </ul> 

    </div> 
</div> 
</body> 
</html> 

여기에 XML 파일입니다 브라우저가 "pagebeforecreate"를 지원하는 경우 내가 감지 할 수있는 방법

<?xml version="1.0" encoding="UTF-8"?> 
<menu> 
<item> 
<title>Awesome Link from XML 1</title> 
<link>http://www.google.com</link> 
</item> 
<item> 
<title>Awesome Link from XML 2</title> 
<link>http://www.gmail.com</link> 
</item> 
</menu> 

jQuery 모바일 이벤트? 아니면이 이벤트가 실행되었는지 감지하는 방법이 있습니까? 이 이벤트가 실행되지 않으면 XML을 다른 함수로로드해야합니다. IE 8은 jQuery Mobile을 지원하지 않지만 XML 파일을 처리하고 링크를 표시하는 것이 좋습니다.

답변

3

http://jquerymobile.com/gbs/

jQuery를 모바일 모든 학년의 브라우저를 지원하기 위해 노력하고 있습니다. 이는 브라우저에 대해 적극적으로 테스트하여 이 가능한 한 최선으로 작동한다는 것을 의미합니다. 브라우저 ( 있지만 궁극적 인 레이아웃이 브라우저에 따라 전체 기능의 우아하게 저하 된 버전 일 수 있습니다) 전체 jQuery를 모바일 CSS와 자바 스크립트를 받게됩니다. 브라우저가 등급 A로 정의 된 경우

, 당신은, 내가 그이를 위해주는 것을 확인하기 위해 IE가없는

$.mobile.gradeA() 

호출 할 수 있습니다 확인하려면하지만이

을하려고 당신은 줄 수
+1

고마워! 그건 잘된거야. "if (! $. mobile.gradeA())"를 테스트했으며 Internet Explorer 8에서 작동합니다. "$ .mobile.gradeA()"이벤트에 대한 설명서가 있습니까? jQuery Mobile 웹 사이트에서 아무 것도 볼 수 없었습니다. – Greg

+1

이 페이지로 되돌아 오는 링크를 제공하여 신고해야합니다. –

관련 문제