jQuery UI – Single Selectable

jQuery UI – Single Selectable

Here, we will make the selectable component for jQuery UI “single selectable”

First of all, we may disable dragging mouse:
Delete "_mouseDrag" function in your jquery-ui.js for “selectable” part.

Now we may write the code for our selectable object:

  1. var xselect;
    $(function() {
        selecting: function() { //here we will make unselected the last chosen item
          if ( xselect && xselect.length > 0 ) {
        selected: function () {
          xselect = $("#selectable1").children(".ui-selected"); //keep the selected in a variable
          $("#selectable1").children(".ui-selected").removeClass("ui-selected"); //make all unselected
          $(xselect).addClass("ui-selected"); //chose the selected object       //and some code… that you may record this xselect object’s id, etc…
          //I am giving an example anyway
          $(".ui-selected").each( function() {
            cid = $(this).attr("id"); //selected object’s id is in "cid" now

For more information you can see my detailed post here;