Trigger all jQuery events bound to an element -


i have attached click handler div surrounds radio inputs. when div clicked sets checked state of radio, trigger events bound radio. there multiple modules bind it, , potentially binding on blur, change, click, dblclick, focus, hover etc.

now use following code:

$('.form-type-radio').click(function(){     $(this).find('input').attr('checked', 'checked').trigger('blur').trigger('change').trigger('click').trigger('dblclick').trigger('focus').trigger('hover'); }); 

but more succinct method - .trigger('all') perfect.

is there way this?

or to:

demo jsfiddle

 $('.form-type-radio').click(function (e) {      if(e.target != this) return;      var input = $(this).find('input')[0],          inputevents = $._data(input, 'events');      $.each(inputevents, function (k, o) {          $(input).triggerhandler(k);      });  }); 

if div contains more 1 input, use for loop:

demo jsfiddle

$('.form-type-radio').click(function (e) {      if (e.target != this) return;      var inputs = $(this).find('input').get();      (var = 0, z = inputs.length; < z; i++) {          var inputevents = $._data(inputs[i], 'events');          $.each(inputevents, function (k, o) {              $(inputs[i]).triggerhandler(k);          });      }  }); 

note: works events bound using jquery.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -