Link to home
Start Free TrialLog in
Avatar of Veilkrand
Veilkrand

asked on

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

Avatar of bugada
bugada
Flag of Italy image

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.
Avatar of Veilkrand
Veilkrand

ASKER

Sorry I think you didn't understand the question.
I need to set original default event before preventdefault call.
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

ASKER CERTIFIED SOLUTION
Avatar of bugada
bugada
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial