如何启用和禁用selectmenu JQuery mobile [英] How to enable and disable selectmenu JQuery mobile

查看:104
本文介绍了如何启用和禁用selectmenu JQuery mobile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用jquery mobile生成的表单.我有一个下拉列表,最初设置为禁用.

I have a form that use jquery mobile to generate. I have a dropdown list that initially set to be disabled.

<div data-role="fieldcontain">
    <label for="role-edit" class="select">Project Role:</label>
    <select name="role-edit" id="role-edit" data-native-menu="false" disabled="disabled" class="edit-projectinput">     
        <option value="Admin">Admin</option>
        <option value="Project Manager">Project Manager</option>
        <option value="User">User</option>
    </select>
</div>

我想使用jquery启用禁用的选择菜单. 我尝试过

I would like to enable the disabled selectmenu using jquery. I tried

$(".edit-projectinput").selectmenu("enable");

但这对我不起作用.

您能告诉我如何启用禁用的选择菜单吗?如果可能,请告诉我如何禁用选择菜单.

Could you please instruct me how to enable the disabled selectmenu, and if possible, show me how to disable one.

这是演示: http://jsfiddle.net/lightbringer/dpv2h/1/

推荐答案

只需:

$(document).ready(function(){
     $("select.edit-projectinput").selectmenu("enable");
});

演示

Demo

请记住,将有2个类别为.edit-projectinput的项,其中一项是转换为选择菜单小部件的实际选择,然后是小部件中的默认选择的span元素,因此,只需专门选择一项即可.您的菜单已经初始化,只需在其上调用enable方法即可.

Remeber than there will be 2 items with the class .edit-projectinput one the real select that is converted to select menu widget and then the one default selected span element in the widget, so just specifically select the one that matters. Your menu is already initialized just a matter of calling enable method on it.

这篇关于如何启用和禁用selectmenu JQuery mobile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆