user626963
user626963

Reputation:

touchstart touches not passed custom eventtype using jQuery .trigger()

I'm trying to replace the eventtype with a custom eventtype...

$(function() {
  $("#control").bind("myTouch", function(e) { 
    b = e.originalEvent.touches.length
  });
  $("#anothercontrol").bind("touchstart", function(e) { 
    a = e.originalEvent.touches.length 
    $("#control").trigger("myTouch"); }
  }); 
});   

a = the correct number and b = null??

Upvotes: 0

Views: 1240

Answers (1)

user626963
user626963

Reputation:

Below seems to work (I guess it goes back to the way jQuery parses the touch events):

$(function() {
  $("#control").bind("myTouch", function(e,event) { 
    b = event.touches.length
  });
  $("#anothercontrol").bind("touchstart", function(e) { 
    a = e.originalEvent.touches.length 
    $("#control").trigger("myTouch",e.originalEvent); }
  }); 
}); 

Upvotes: 2

Related Questions