programing

jquery mobile collapsable and galaxy tab 10.1 json 응답으로 무작위 응답 제공

sourcejob 2023. 10. 11. 20:41
반응형

jquery mobile collapsable and galaxy tab 10.1 json 응답으로 무작위 응답 제공

jquery mobile과 json을 파싱하는 것은 처음입니다 - 많은 연구를 했지만 아무 소용이 없었습니다.설정 타임아웃 기능에서 10초 지연을 시도했습니다.

내 앱은 내 삼성 갤럭시 s2에서 올바르게 작동하지만 내 삼성 갤럭시 태블릿 10.1에서는 다음과 같이 작동합니다.

최신 사용하기jquery 1.2.0그리고.jquery-1.7.2

불러봅니다getlocations2.php4개 이하의 아이템을 반납하면 접이식 세트가 올바르게 열리고 닫힙니다.5개 이상의 물품을 반품하는 경우:

  1. 접을 수 있는 상단을 클릭하여 펼칩니다. 아무 일도 일어나지 않습니다.
  2. 두번째 접이식 h3을 클릭하면 먼저 접이식으로 열립니다.
  3. 그 후에는 무작위로 h3를 다시 확장할 수 있지만 보통 마지막 h3를 터치하여 열지 못했습니다.
  4. 그것은 잠깐동안 올바르게 작동할 수 있습니다.

어떤 팁이라도 감사드립니다.

코드 :

function doajax2($vurl,$vdata,$vtype,$vfrom){   
    $.ajax({
        url: $vurl,
        dataType: 'json',
        data:$vdata,
        async: false,
        success: function(rtndata) {
            $.mobile.hidePageLoadingMsg(); //alert(result.toSource())   
            rtndata2=(JSON.stringify(rtndata, null, 4));
            rtndata2=rtndata2.substring(13);
            rtndata2=rtndata2.slice(0, -2)

            var res = eval(rtndata2);           
            $('.displaylocations').html('');    
            g_html=res[0].brand;

            if (res[0].id> -1){
                g_html=g_html+'<div data-role="collapsible-set" data-theme="f" >';
                for (var i=0;i<res.length;i++){
                //for (var i=0;i<6;i++){            
                    lochtml('loc',i,res[i].locid,res[i].loccode1,res[i].head,res[i].desc,res[i].lang,res[i].lat1,res[i].long1,res[i].img1,res[i].limit);        
                }
                g_html=g_html+'</div>';
            }

            console.log('g_html'+g_html);
            $('.displaylocations').css('display','none');           
            $(".displaylocations").html(g_html);    
                    //  $(".displaylocations").html(str);   


            setTimeout(function(){ //make sure displaylocations has been updated
                $('#lhead2').html('Tuhura <span lang="en">Locations</span>');
                $('.displaylocations').trigger('create');
                $('.displaylocations').css('display','block');
                $( ".displaylocations" ).collapsibleset( "refresh" );

            },300);
        },
        error: function(faildata){
            switch ($vfrom) {
                case "region"   : $("#lhead3").html('Region Info Unavailable...');break
                case "locs"     :   $("#lhead2").html('Locations Unavailable...');break;
            }
        }
    });
}

function lochtml($vtype,$vno,$locid,$loccode1,$head,$desc,$vlang,$vlat1,$vlong1,$img1,$limit) {
console.log('lochtml '+$desc);
        g_html=g_html+  "<div class='locgoh'>";
        g_html=g_html+      '<a href="#" onclick="getsitedetails('+"'gps','"+$locid+"','"+$loccode1+"','s','sites','"+$vlang+"',1,0,'x',"+$vlat1+","+$vlong1+')">';
        g_html=g_html+ '<img src="http://tuhtop.co.nz/images/rightarrow.png" width="30px" height="30px" /></a>';                                                                            
        g_html=g_html+  '</div>';
        g_html=g_html+'<div data-role="collapsible" class="loccollapse" data-theme="f" div="coldiv">';              
        g_html=g_html+  '<h3>'+$head+'</h3>';                                               
        g_html=g_html+  '<p><div class="locli0">';                                  
        g_html=g_html+      '<span class="li1">' +$desc+ '</span>';                     
        g_html=g_html+      '<span class="li2"><a href="#" onclick="getsitedetails('+"'gps','"+$locid+"','"+$loccode1+"','s','sites','"+$vlang+"',1,0,'x',"+$vlat1+","+$vlong1+')">';
        g_html=g_html+      '<img src=\''+$img1+'\' width=\'120"\' height=\'120\' alt=\''+$img1+'\'/></a>';         
        g_html=g_html+      '</span>';      
        g_html=g_html+  '</div></p>';       
        g_html=g_html+'<div class="clearfloat"></div>';             
        g_html=g_html+'</div>';

}

제가 틀리면 수정해주세요. 코드를 읽을 때 여러 가지 문제가 있을 수 있습니다.

우선 g_html 변수의 참조, 함수 lochtml에서 html을 반환하고 for loop에서 html을 이렇게 빌드하면 더 가독성이 좋습니다.

    for (var i=0;i<res.length;i++){
        g_html=g_html+lochtml('loc',i,r...)
    }

둘째, g_html의 초기값을 res[0]brand로 설정하고 있는데 값이 얼마입니까?

셋째, collapsible-set div에 대해 생성되는 것은 다음과 같습니다.

    the res[0].brand above 
    <div data-role="collapsible-set" data-theme="f">
        <div class='locgoh'>
            <a ...>
                <img />
            </a>
        </div>
        <div data-role="collapsible" class="loccollapse" data-theme="f" div="coldiv">
            <h3>...</h3>
            <p>...</p>
            <div class="clearfloat"></div>
        </div>
        ...
        ...
    </div>

이것은 jQuery Mobile이 data-role=" collapsable-set"의 콘텐츠에 대해 기대했던 것이 아니었습니다. <div data-role=" collapsable-set"> 안에는 <div data-role=" collapsable">만 있어야 합니다.<div class='locgoh'><h3> 안으로 옮기는 것을 제안합니다.

넷째, <div class="clearfloat">이 필요합니까? 접이식 안에 태그 p를 띄웠습니까?이전에 jQM 위젯과 함께 "float"을 사용할 때 문제가 있었습니다.게다가 맑은 물이 필요 없다면 제거하는 것이 좋습니다.

마지막으로 접이식 집합 ('refresh')을 컨테이너가 아닌 <div data-role="collapsable-set">에서 호출해야 한다고 생각합니다.

언급URL : https://stackoverflow.com/questions/13829283/jquery-mobile-collapsible-and-galaxy-tab-10-1-json-response-gives-random-respons

반응형