Click on jQuery Sortable list does not blur input

2020-06-20 16:05发布

问题:

I can blur my input by clicking anywhere on the page except the jQuery Sortable list. How can I fix this? UPD: demo

回答1:

$('sortable').mousedown(function(){
  document.activeElement.blur();
});


回答2:

Take a look at the cancel option from the jquery-ui

   $("#sortable").sortable(cancel: 'input');

You'll have to remove the $("#sortable").disableSelection();

See my jsfiddle

UPDATE

I understand your problem. Because jQuery stops the default functionality of the browser when sorting a list, the blur is never called for that field. You'll have to force the field to blur.

See my jsfiddle. I use change to call the blur, you can change 'change' to 'start' if you want the blur to always happen.



回答3:

It is a bug of jquery sortable, which will be fixed in jqueryui 2.0.0. See Sortable: clicking a sortable item does not cause form element to blur



回答4:

To limit the handle to a specific element that is not a input solved it for me.