How to enable a ontouchmove event after calling a preventdefault()

I have an Iphone webapp with several views. To stop scroll bouncing I use a preventdefault() for the ontouchmove event on load.
But I have a view with long text where I need to activate scrolling. But only for that view.

Thanks
document.body.ontouchmove = function(e){
	  e.preventDefault(); 
	}

Open in new window

VeilkrandAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bugadaCommented:
Sorry I'm not familiar to IPhone, but i think you have to remove the handler like that in that view:

document.body.ontouchmove = null;

or if a 'view' is a particular element and not a page

yourview.ontouchmove = null;

Just my 2 cents.
0
VeilkrandAuthor Commented:
Sorry I think you didn't understand the question.
I need to set original default event before preventdefault call.
0
VeilkrandAuthor Commented:
Would be possible to implement something like this to restore previous default behaviour of the event?
var defaultEvent;
document.body.ontouchmove = function(e){
  defaultEvent=e;
}
 
document.body.ontouchmove = function(e){
  e.preventDefault();
}
 
document.body.ontouchmove = defaultEvent;

Open in new window

0
bugadaCommented:
No may be something like that but it seems to be a non sense:

var defaultEvent = document.body.ontouchmove;
 
document.body.ontouchmove = function(e){
  e.preventDefault();
}
 
document.body.ontouchmove = defaultEvent;

I can't understand what you are doing: if you need to preventDefault for all page but not for an object you can do something like that:




document.body.ontouchmove = function(e){
  e = e || window.event;
  var view = e.target || e.srcElement;
  if (view.id = "yourview") {
     return true;
  }
  e.preventDefault();
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Components

From novice to tech pro — start learning today.