javascript - Determine whether an event is invoked by .trigger() -
is there way determine whether or not .change
function below being called jquery .trigger
?
$('input[name=transactiontype]').change(function () { //clear out values $('input:text').val(''); $('input:text').text(''); //display input fields var radiovalue = $(this); $('#rightdiv').children().each(function () { if (radiovalue.attr('id') == $(this).attr('id')) { $(this).show(); } else { $(this).hide(); } }); }).filter(':checked').trigger('change');
you can use event.istrigger
$('input[name=transactiontype]').change(function (e) { if(e.istrigger){ //this triggered using trigger('change') or .change() etc } }
this flag set when triggered mentioned above otherwise may undefined. not able find documentation though.
but see being set in jquery code in trigger method.
// trigger bitmask: & 1 native handlers; & 2 jquery (always true) event.istrigger = onlyhandlers ? 2 : 3;
Comments
Post a Comment