How can I trigger a change event on a jQuery UI slider?
I thought it would be
$(\'#slider\').trigger(\'slidechange\');
but that do
Yet another way, which is handy for UI widgets like autocomplete, is to access the event directly via the data method. JQuery stores all of its event hookup info using .data("events"), so if you use that property you can access the events directly. On some UI components (eg. autocomplete) the events aren't even attached to the main element, they're attached to the UI object itself. Luckily, that UI object is also available in data.
So, without further ado, here's how you'd invoke the autocomplete's select event:
$("#autoComplete").data("autocomplete").menu.select()
Or, (getting back to sliders) to trigger a slider's change:
$("#slider").data("slider")._change()
Trigger is still the best way of course, since it actual utilizes the event system, but on the more complex widgets where "$(elem).trigger" won't be enough, this approach is handy.
* EDIT *
Just figured out that you actually can "trigger" the event properly with this method, using the widget's "secret" _trigger property. For example:
$("#autoComplete").data("autocomplete")._trigger("select", fakeEvent, fakeItem)
Hope this helps someone.