Open ebody opened 4 years ago
This is not an issue with touch-punch (which turns touch gestures into mouse movements), but more to do with how jquery-ui works.
Basically, you have to re-assert the draggable after adding elements so far as I know
Thanks... This works:
$( document ).ready(function() {
/**
* orientationchange
*/
$(window).on('orientationchange', function(e){
$('main').append('<div>Orientationchange Result</div>');
makeItDraggable();
});
$('main > div:eq(0)').click(function(){
$('main').append('<div>Click Result</div>');
makeItDraggable();
});
/**
* draggable
*/
makeItDraggable();
function makeItDraggable(){
$('main > div').draggable({
cursor: 'pointer'
});
}
});
The only problem is that you can then get multiple draggable events on existing div elements. You should ideally use something like:
$( document ).ready(function() {
/**
* orientationchange
*/
$(window).on('orientationchange', function(e){
$('main').append('<div c;lass="addDraggable">Orientationchange Result</div>');
makeItDraggable();
});
$('main > div:eq(0)').click(function(){
$('main').append('<div c;lass="addDraggable">Click Result</div>');
makeItDraggable();
});
/**
* draggable
*/
makeItDraggable();
function makeItDraggable(){
$('main > div. addDraggable').draggable({
cursor: 'pointer'
});
$('main > div. addDraggable').removeClass('addDraggable');
}
});
Elements loaded after events are not draggable.