jQuery UI selectable, how to programmatically select option

If you need to programmatically select an option, using events, so that your callbacks are called then you can do the following:
Suppose we have a ul element with id mySelectUlID, and i want to add an extra element to the end of it and also select it.

This is done like this:

    $('#mySelectUlID.ui-selected').addClass('ui-unselecting').removeClass('ui-selected');
    $('#mySelectUlID').append('<li class="ui-widget-content ui-selectee ui-selecting">another</li>');

    $('#mySelectUlID').selectable("refresh");

    $('#mySelectUlID').data("ui-selectable")._mouseStop(null);

The code is valid for the latest jQuery 1.10 and is self explaining i believe.

Cheers.