下拉列表是一个jQuery自定义选择菜单

时间:2014-02-21 19:45:05

标签: javascript jquery html asp.net jquery-mobile

我正在尝试将我的下拉列表设为jQuery Mobile自定义选择菜单(http://demos.jquerymobile.com/1.4.1/selectmenu-custom/)(http://api.jquerymobile.com/selectmenu/):

以下是它的意思:

  

要在特定选择上使用自定义菜单,只需添加   data-native-menu =“false”属性。或者,这也可以   以编程方式设置选择菜单的nativeMenu配置选项   在绑定到mobileinit事件的回调中为false来实现   同样的效果。这将全局使所有选择使用自定义菜单   默认情况下。在jQuery之后,必须在页面中包含以下内容   加载但是在加载jQuery Mobile之前。

$(document).on( "mobileinit", function() {  
$.mobile.selectmenu.prototype.options.nativeMenu = false; });

所以我首先尝试将其添加到我的服务器控件中:

<asp:DropDownList runat="server" ID="ddlLocJobPhOpt" data-mini="true" data-native-menu="false"></asp:DropDownList>

我似乎像示例一样呈现:

<select name="ddlLocJobPhOpt" id="ddlLocJobPhOpt" data-mini="true" data-native-menu="false">
    <option value="Select" data-theme="a">Select</option>
    <option value="100101" data-theme="a">100101</option>
</select>

接下来我尝试在jQuery和jQuery mobile加载的地方之间添加jQuery:

<script type="text/javascript" src="Scripts/jquery-2.0.3.min.js"> </script>
<script>
    $(document).on("mobileinit", function () {
        $.mobile.selectmenu.prototype.options.nativeMenu = false;
    });
</script>
<script src="Scripts/CustomScripts/jquery.mobile-1.4.1.js"></script>

他们都没有做任何事情。我做错了什么?

0 个答案:

没有答案