views:

714

answers:

2

I'm working with jQTouch and I'm using the animations to link to different href #ids on the same page. On some pages I would want to disable scrolling, and others I want to enable scrolling. By setting disabled scrolling onload then enabling it onlick to another id it will work. However, I cannot switch back to disabled scrolling. Any ideas?

function e(){ document.ontouchmove = function(event){ } } function d(){ document.ontouchmove = function(event){ event.preventDefault(); } }
+1  A: 

Turn the move off by the div. For example:

<div id="dont_move">
   <ul>
      <li>Item 1</li>
      <li>Item 2</li>
   </ul>
<div id="scroll_me">
   <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
      <li>Item 4</li>
      <li>Item 5</li>
      <li>Item 6</li>
      <li>Item 7</li>
      <li>Item 8</li>
      <li>Item 9</li>
      <li>Item 10</li>
      <li>Item 11</li>
      <li>Item 12</li>
   </ul>
</div>

And then in your script add:

$('#dont_move')[0].addEventListener('touchmove', function(e){ e.preventDefault(); });    
Kris Erickson
A: 

$('#dont_move')[0].addEventListener('touchmove', function(e){ e.preventDefault(); }, false);

JohnZ