2012-02-28 4 views
1

jquerymobile을 사용하여 앱을 제작 중입니다. 고정 머리글, 바닥 글, 스크롤 가능한 내용을 얻기 위해 코드를 다음과 같이 사용하고 있습니다 : iscroll.js. 문제는 콘텐츠 div를 스크롤 할 수 없다는 것입니다. Pls 날 도와 줘요.jquerymobile로 iscroll 사용

enter code here<body onload="loaded()"> 
<div data-role="page" id="detail"> 
    <div class="fixedHeader"> 
     </div> 
     <div id="wrapper" > 
       <div id="scroll-content"> 
     <div data-role="content"> 
     <!-- dynamic content goes here --> 
     dynamic content goes here 
    </div> 
    </div> 
    </div> 
    <div class="fixedFooter" ></div> 
</div> 
#wrapper { 
    position:absolute; z-index:1; 
    top:45px; bottom:48px; left:0; 
    width:100%; 

    overflow:auto; 
} 
#scroller { 
    position:relative; 
/* -webkit-touch-callout:none;*/ 

    float:left; 
    width:100%; 
    padding:0; 
} 

자바 스크립트 코드

var myScroll; 
function loaded() { 

    myScroll = new iScroll('wrapper', { 

onBeforeScrollStart: function (e) { 
var target = e.target; 
while (target.nodeType != 1) target = target.parentNode; 

if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') 
e.preventDefault(); 
} 
}); 
} 

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); 
document.addEventListener('DOMContentLoaded', loaded, false); 
+0

어디 JS 코드는? – ghostCoder

+0

pageloaded 이벤트에서 iscroll을 새로 고쳤습니까? –

+0

나는 js 코드 – user969275

답변

0
i got iscroll working in jquerymobile by editing js as 

    var myScroll = []; 

    $(document).delegate('[data-role="page"]', 'pageshow', function() { 

     var $page = $(this); 

     // setup iScroll 
     $($page.find('#wrapper')).each(function(index) { 

      var scroller_id = $(this).get(0); 

      myScroll.push(
       new iScroll(scroller_id, { 

       useTransform: false, 
       onBeforeScrollStart: function (e) { 
var target = e.target; 
while (target.nodeType != 1) target = target.parentNode; 

if (target.tagName != 'SELECT'&& target.tagName !='option'&& target.tagName !='option' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') 
e.preventDefault(); 
e.stopPropagation(); 
} 

      })); 
    }); 

}); 

$(document).delegate('[data-role="page"]', 'pagehide', function() { 

    // unset and delete iScroll 
    for (x in myScroll) 
    { 
     myScroll[x].destroy(); 
     myScroll[x] = null; 
     myScroll.splice(x, 1); 
    } 

}); 

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); 
+0

을 업데이트했습니다. 필드가 작동하지 않습니다 .pls help me – user969275