If we bind an event clickto a link as
$("linkSelector").click(function(){ ... });
then we can also easily force this event handler, even if the user hasn’t clicked the link.
$("linkSelector").click(function() { ... }).click();
But in my case, I'm using a jQuery Slider widget , which has an event slideto which an event handler can bind. I wonder how we can programmatically execute our events?
I tried, but none of them work:
$("sliderSelector").slider({ slide: function(){ ... } }).slide();
$("sliderSelector").slider({ slide: function(){ ... } }).slider("slide");
$("sliderSelector").slider({ slide: function(){ ... } }).trigger("slide");
I know that I could use a named function instead of an anonymous one, but I do not consider this a solution, because I can call the function with any arguments that I want when the event fires slide, to ensure the correct values set by the slider.