jQuery Mobile如何设置hidePlaceholderMenuItems值

时间:2013-02-02 19:11:12

标签: jquery-mobile

我有一个使用json填充的选项,但jquery mobile select不显示默认的选定值。我已阅读文档,他们说需要设置以下内容:

$.mobile.selectmenu.prototype.options.hidePlaceholderMenuItems = false;

但我真的不知道该怎么做

1 个答案:

答案 0 :(得分:1)

您需要在jQuery Mobile初始化之前在mobileinit事件中设置它,如下所示:

<head>
    <title>jQM Complex Demo</title>
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0"/>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script>
        $(document).on("mobileinit", function () {
            $.mobile.selectmenu.prototype.options.hidePlaceholderMenuItems = true;
        });        
    </script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>    
</head>

示例:http://jsfiddle.net/Gajotres/VmsRg/

相关问题