I need to trigger a custom event in the callback of a trigger call, but I can't get it to work.
I tried this:
var $input = $( ".ui-popup-container" ).find( "input" ).eq(2);
function runtests () {
console.log("clicked the input");
};
$input.trigger('click', runtests());
and this:
var $input = $( ".ui-popup-container" ).find( "input" ).eq(2);
$input.trigger('click', function(){
console.log("clicked the input");
}
Neither of which works.
Question:
How do I get a callback function to run when I'm triggering a click on an element?
[]as per jquery API, but also does not work.triggerdoes not accept any callbacks.$input.trigger('click')triggers theclickevent on the$inputelements, i.e. it will execute theclickevent handlers bound to those elements. It looks like you have bindruntestto$input, but I'm not sure what your want exactly.