gpt4 book ai didi

jquery mobile - 弹出窗口中的自定义选择菜单

转载 作者:行者123 更新时间:2023-12-03 22:47:05 24 4
gpt4 key购买 nike

请找到下面的 fiddle http://jsfiddle.net/yesvin/Xj8p8/

<ul data-role="listview">
<li data-role="fieldcontain">
<label for="basic">Text Input:</label>
<input type="text" name="name" id="basic" value="" />
</li>
<li data-role="fieldcontain">
<label for="basic">Text Input:</label>
<input type="text" name="name" id="basic" value="" />
</li>
<li data-role="fieldcontain">
<label for="pageselect">page select</label>
<select name="pageselect" id="pageselect" data-native-menu="false">
<option value="">Choose One</option>
<option value="">pageselect opt 1</option>
<option value="">pageselect opt 2</option>
<option value="">pageselect opt 3</option>
</select>
</li>
<li data-role="fieldcontain">
<label for="basic">Text Input:</label>
<input type="text" name="name" id="basic" value="" />
</li>
</ul>

<a href="#pop" data-rel="popup" data-position-to="window" data-role="button" id="farmer_family_member">Add Popup</a>


<div data-role="popup" id="pop">
<ul data-role="listview">
<li data-role="fieldcontain">
<label for="popupselect">popup select</label>
<select name="popupselect" id="popupselect" data-native-menu="false">
<option value="">popup select opt 1</option>
<option value="">popup select opt 2</option>
<option value="">popup select opt 3</option>
</select>
</li>
<li data-role="fieldcontain">
<label for="basic">Text Input:</label>
<input type="text" name="name" id="basic" value="" />
</li>
<li data-role="fieldcontain">
<label for="basic">Text Input:</label>
<input type="text" name="name" id="basic" value="" />
</li>
<li data-role="fieldcontain">
<label for="basic">Text Input:</label>
<input type="text" name="name" id="basic" value="" />
</li>
<li data-role="fieldcontain">
<label for="basic">Text Input:</label>
<input type="text" name="name" id="basic" value="" />
</li>
</ul>
</div>

与我的页面中的相同,当我在移动设备中查看该页面时,它出现了一些问题,

  1. 当我单击“添加弹出窗口”按钮时,它会打开一个弹出窗口,该弹出窗口内有一个选择菜单,并且 data-native-menu=false 表示该选择菜单不起作用。我如何启用它?

  2. 如果我更改弹出窗口内的“popupselect”菜单,则会打开“pageselect”菜单。我该如何防止这种情况发生?

请多多指教...

提前致谢。

最佳答案

第一个答案

简短的回答是你不能这样做。我知道,这听起来很愚蠢,但是 jQuery Mobile 对弹出窗口有一些限制,主要限制是不能链接弹出窗口。因为自定义选择菜单只是另一个弹出窗口,所以无法从弹出窗口中显示。

Note: Chaining of popups not allowed

The framework does not currently support chaining of popups so it'snot possible to embed a link from one popup to another popup. Alllinks with a data-rel="popup" inside a popup will not do anything atall.

This also means that custom select menus will not work inside popups,because they are themselves implemented using popups. If you place aselect menu inside a popup, it will be rendered as a native selectmenu, even if you specify data-native-menu="false".

官方文档:http://api.jquerymobile.com/popup/

此问题有一个可用的解决方法,但在本例中无法使用。要解决此问题,需要先关闭第一个弹出窗口,然后才能打开第二个弹出窗口。不幸的是,这在这里不可行。

第二个答案

这也称为事件失败。这是一个冷酷的 javascript 错误,好吧,这不是错误本身,因为 javascript 从来就不是这样工作的。

基本上当你点击一个元素时,点击事件就会落到下面的元素上。

可以通过以下功能来防止这种情况:

这里有一个 jsFiddle 示例,以便您可以理解这个问题:http://jsfiddle.net/Gajotres/Xz2np/

$('#page1').live('pagebeforeshow',function(e,data){
$('.someDiv').live('click', function (e) {
alert('Event is not going to propagate to content div, thus not hiding a header');
event.stopPropagation();
event.stopImmediatePropagation();
});
});

要理解这个问题,只需单击 DIV 示例,然后注释这两行,再次运行示例,然后再次单击 DIV。

最后一件事

这听起来很粗糙,但还是需要说一下。不要忘记不时接受答案。我可以看到我对您之前的问题给出了很少的答案。我通常不介意这一点,但其他人会介意,而且他们不会帮助你。

关于jquery mobile - 弹出窗口中的自定义选择菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16059431/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com