Search code examples
javascriptiosdom-eventstouch-event

touchend event not fired on iOS when it starts on a div


I have some problem with a touchend event on iOS:

var target;

window.addEvent('domready', function(){

    target = $('mydiv');
    target.addEvents({ 'touchstart': onTouchStart });
});

function onTouchStart(){

    console.log('touch start');
    target.addEvents({ 'touchend': onTouchEnd });
}

function onTouchEnd(){

    console.log('touch end');
}

Everything should work fine, but touchend is not fired when I'm on this div. This div is nothing special, it's just a wrapper for some images and has this CSS:

#albums-wrapper{ position: absolute; width: 10000px; height: 100%; }

Solution

  • In this line

    target.addEvents({ 'touchend': onTouchEnd });
    

    target is undefined, I believe