jqueryUI Sortable: handling .disableSelection() on form inputs

solved . bit of hack but works! .. any comments how i can do this better?

apply .sortable() and then enable text-selection on input fields :


$("#list").sortable({
  stop: function () {
    // enable text select on inputs
    $("#list").find("input")
     .bind('mousedown.ui-disableSelection selectstart.ui-disableSelection', function(e) {
      e.stopImmediatePropagation();
    });
  }
}).disableSelection();

// enable text select on inputs
$("#list").find("input")
 .bind('mousedown.ui-disableSelection selectstart.ui-disableSelection', function(e) {
  e.stopImmediatePropagation();
});

A little improvement from post of Zack - jQuery Plugin

$.fn.extend({
    preventDisableSelection: function(){
        return this.each(function(i) {
            $(this).bind('mousedown.ui-disableSelection selectstart.ui-disableSelection', function(e) {
                e.stopImmediatePropagation();
            });
        });
    }
});

And full solution is:

$("#list").sortable({
  stop: function () {
    // enable text select on inputs
    $("#list").find("input").preventDisableSelection();
  }
}).disableSelection();

// enable text select on inputs
$("#list").find("input").preventDisableSelection();

jQuery UI 1.9

$("#list").sortable();
$("#list selector").bind('click.sortable mousedown.sortable',function(e){
    e.stopImmediatePropagation();
});

selector = input, table, li....