简体   繁体   English

jQuery UI禁用输入字段

[英]Jquery-UI disabling input fields

Using Foundation Framework and PHP 使用Foundation Framework和PHP

I have a couple of simple input type=text form fields which appear to get focus (cursor blinks inside them) but they refuse to accept any keyboard input. 我有几个简单的输入type = text表单字段,它们看起来很吸引人(光标在其中闪烁),但它们拒绝接受任何键盘输入。 After some trial and error, I discovered that if I disable the Jquery-ui.js script, the inputs work ok. 经过一番尝试和错误后,我发现如果禁用Jquery-ui.js脚本,则输入正常。

It appears that Jquery-ui is somehow disabling the fields. 看来Jquery-ui以某种方式禁用了这些字段。 Does anyone have any idea why this might be and what a workaround might be? 有谁知道这可能是什么以及什么解决方法? I need to keep Jquery-ui as I have some draggable/droppable items. 我需要保留Jquery-ui,因为我有一些可拖动/可拖放的项目。

<form action="#" method="post">`
  <input id="formLength" type="text" >`
  <input id="formWidth" type="text">`
</form>`

I'm guessing here, but i've seen errors like these when i had conflicting jquery mask plugins in the project. 我在这里猜,但是当我在项目中遇到冲突的jquery mask插件时,我已经看到类似的错误。 I needed to use both, so i had to deactivate the duplicated selectors from one of the libs so it doesn't activated for the same input. 我需要同时使用两者,因此我不得不停用其中一个库中的重复选择器,因此对于同一输入它不会被激活。

Not enough information to answer the direct question. 没有足够的信息来回答直接问题。 However, as a side note, you can use the jQuery UI interactions--mouse, position, draggable, droppable, position, resizable, selectable, sortable--without having to use the widgets. 但是,作为一个附带说明,您可以使用jQuery UI交互-鼠标,位置,可拖动,可放置,位置,可调整大小,可选择,可排序-无需使用小部件。 The only dependencies are core.js and widget.js(the widget factory). 唯一的依赖项是core.js和widget.js(小部件工厂)。

I've got a potential workaround for you. 我为您提供了一个可能的解决方法。

First create two instances of jQuery 首先创建两个jQuery实例

<script type="text/javascript">
    var $jOriginal = jQuery.noConflict(); 
</script>

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

<script type="text/javascript">
    var $jNew = jQuery.noConflict(); 
</script>

Now, use new jQuery instance in place of the old one 现在,使用新的jQuery实例代替旧的

<script type="text/javascript">
    $jNew('#selector).doSomething(); //Will use new jquery library
    $jOriginal('#selector).doSomethingElse(); //Will use original jquery library
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM