点击 jQuery 可排序列表不会模糊输入

发布于 2024-12-27 05:42:19 字数 120 浏览 2 评论 0原文

我可以通过单击页面上除 jQuery 可排序列表之外的任何位置来模糊输入。我该如何解决这个问题? UPD:演示

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

稀香 2025-01-03 05:42:19
$('sortable').mousedown(function(){
  document.activeElement.blur();
});
$('sortable').mousedown(function(){
  document.activeElement.blur();
});
江南月 2025-01-03 05:42:19

看看 jquery-ui 中的 cancel 选项,

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

您必须将其删除$("#sortable").disableSelection();

请参阅我的 jsfiddle

更新

我理解您的问题。因为 jQuery 在对列表进行排序时会停止浏览器的默认功能,所以永远不会对该字段调用模糊。你必须迫使场变得模糊。

请参阅我的 jsfiddle。我使用更改来调用模糊,如果您希望模糊始终发生,您可以将“更改”更改为“开始”。

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.

野味少女 2025-01-03 05:42:19

这是jquery sortable的一个bug,将在jqueryui 2.0.0中修复。请参阅可排序:单击可排序项目不会导致表单元素模糊

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

来日方长 2025-01-03 05:42:19

将句柄限制为不是输入的特定元素为我解决了这个问题。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文