mhartington
mhartington

Reputation: 7025

Prevent scrolling on only certain pages in Jquery Mobile

I'm using iScroll on a single page in my Jquery Mobile document because it has some touch features and I wanted to prevent the user from accidentally scrolling away from the main content. So I add the event listener

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

But I want this to only effect the main page where I have my iScroll enabled. So I figured I'd use the pageload event to bind the event listend to the specific page I needed.

$('#scroll').bind('pageload', function(){
    document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false);// JavaScript Document
    });

But I still cant get it to work on the one page I want. Any ideas?

Upvotes: 0

Views: 271

Answers (1)

mhartington
mhartington

Reputation: 7025

Never mind, got it

scroll.addEventListener('touchmove', function(e) { 
    e.preventDefault(); }, false);

Upvotes: 1

Related Questions