Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Mobile : replace click event by vclick event

Is there a way to replace all click event by vclick event in jQuery mobile?

The only solution I've found so far is to register a vclick event as below

$('a').bind("vclick", function (ev) {
  // Do Some stuff
  ev.preventDefault();
});

The problem is that this solution doesn't prevent jQuery mobile click event to fire so clicks are triggered twice

like image 253
Laurent Avatar asked Sep 11 '12 06:09

Laurent


2 Answers

For some reason, I got the following to work:

$('a').bind('vclick click',function(e){
  e.preventDefault();
   //do some stuff//
 })

Without the e.preventDefault() the event fires twice. With it, it only fires once (but it does fire)

This is similar to what you stated, but may be more all encompassing.

like image 143
dgo Avatar answered Sep 19 '22 15:09

dgo


$("#elementId").bind('vclick',function(event){
event.preventDefault();
 //your code..
});

this is working properly.

like image 45
Vaishali Modi Avatar answered Sep 19 '22 15:09

Vaishali Modi