我正在尝试将在 1.0.1 和 jquery 1.6.4 版本上运行的旧 jquery 移动站点升级到最新版本,并且在替换某些在选择弹出按钮上工作的 jquery 部分时遇到问题。以下是旧版本生成的HTML
<div class="ui-selectmenu ui-overlay-shadow ui-corner-all ui-body-a pop in" style="top: 30px; right: 30px;">
<div class="ui-header ui-bar-a">
<h1 class="ui-title">Search Results</h1>
<a class="ui-btn-left ui-btn ui-btn-up-a ui-btn-icon-notext ui-btn-corner-all ui-shadow" href="#" data-iconpos="notext" data-icon="delete" title="Close" data-theme="a" style="display: none;">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">Close</span>
<span class="ui-icon ui-icon-delete ui-icon-shadow"></span>
</span>
</a>
</div>
<ul id="action_menu-menu" class="ui-selectmenu-list ui-listview" role="listbox" aria-labelledby="action_menu-button" data-theme="a">
<li class="ui-selectmenu-placeholder ui-btn ui-btn-up-a ui-btn-icon-right ui-li ui-btn-active" data-icon="false" data-option-index="0" role="option" tabindex="0" data-theme="a" aria-selected="true">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a class="ui-link-inherit" href="#">Search Results</a>
</div>
</div>
</li>
<li class="ui-btn ui-btn-icon-right ui-li ui-btn-up-a" data-icon="false" data-option-index="1" role="option" tabindex="-1" data-theme="a" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a class="ui-link-inherit" href="#">Home</a>
</div>
</div>
</li>
<li class="ui-btn ui-btn-icon-right ui-li ui-btn-up-a" data-icon="false" data-option-index="2" role="option" tabindex="-1" data-theme="a" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a class="ui-link-inherit" href="#">Email</a>
</div>
</div>
</li>
</ul>
</div>
以下是我当前代码生成的 HTML
<div id="action_menu-listbox-screen" class="ui-popup-screen in"></div>
<div id="action_menu-listbox-popup" class="ui-popup-container ui-popup-active" style="max-width: 1564px; top: 30.0001px; left: 14px;" tabindex="0">
<div id="action_menu-listbox" class="ui-selectmenu ui-popup ui-body-a ui-overlay-shadow ui-corner-all">
<div class="ui-header ui-bar-a">
<h1 class="ui-title">Search Results</h1>
</div>
<ul id="action_menu-menu" class="ui-selectmenu-list ui-listview" role="listbox" aria-labelledby="action_menu-button" data-theme="a" data-divider-theme="b">
<li class="ui-selectmenu-placeholder ui-btn ui-btn-up-a ui-btn-icon-right ui-li ui-first-child" data-option-index="0" data-icon="false" data-placeholder="true" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="a" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a class="ui-link-inherit" href="#" tabindex="-1">Search Results</a>
</div>
</div>
</li>
<li class="ui-btn ui-btn-icon-right ui-li ui-btn-up-a" data-option-index="1" data-icon="false" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="a" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a class="ui-link-inherit" href="#" tabindex="-1">Home</a>
</div>
</div>
</li>
<li class="ui-btn ui-btn-icon-right ui-li ui-last-child ui-btn-up-a" data-option-index="2" data-icon="false" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="a" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a class="ui-link-inherit" href="#" tabindex="-1">Email</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
除了具有我正在努力完全理解和替换的实时方法的 javascript 之外,我没有更改旧代码。如下
<script type="text/javascript">
$(document).bind("mobileinit", function(){
$.mobile.listview.prototype.options.theme= "c";
$.mobile.defaultTransition = 'none';
$.mobile.pushStateEnabled = false;
$.extend( $.mobile , {
ajaxFormsEnabled : false,
ajaxLinksEnabled : false,
ajaxEnabled:false,
// loadingMessage: false
});
});
</script>
<script src="</jquery.mobile-1.0.1.min.js" type="text/javascript"></script>
<%--Script added by B37914 for CR43399 on 7th March,2012--%>
<script src="/m_alert.js" type="text/javascript"></script>
<script src="/m_common.js" type="text/javascript"></script>
<script>
var mobileMainViewUrl = 'http;//www.yahoo.com';
var urlForEmailAction = document.location.href;
$('#header-logo').click(function(){alert("this is the header alert");});
$(document).bind("mobileinit", function(){
$.mobile.defaultTransition = 'none';
});
**
$("select[id='action_menu']").live("change",actionHandler);
**
$(document).ready(function(){
if($("li[class*='ui-btn-icon-right']")!=null){
$("li[class*='ui-btn-icon-right']").each(function(ind,elm){
var anch=$(this).find("a[class*='ui-link-inherit']");
var arrowIcn=$(elm).find("span[class='ui-icon ui-icon-arrow-r ui-icon-shadow']");
if(anch !=null && arrowIcn!=null){
$(arrowIcn).appendTo(anch);
}
});
}
});
function showActionMenu(assetId,assetType){
var language=document.getElementById("m_lang").value;
var pageTitle = $('title').html();
pageTitle = pageTitle.replace("&","and");
pageTitle = pageTitle.replace("amp;","");
pageTitle = pageTitle.replace("&","and");
//changed by b36050 for cr-48634 on 17 jan 2013
callActionButton('action_menu',pageTitle,urlForEmailAction,true,assetId,assetType,deleteFavorite,language);
}
</script>
请在http://jsfiddle.net/hgafoor/85qy3/检查生成这两个 HTML 和 .js 文件的代码
我尝试了各种选项,但是当我使用 click 时,我无法以某种方式获得选项的值。我尝试使用#action_menu-menu 作为选择器并尝试绑定和委托我不明白为什么在较新的版本中添加action_menu 的id 作为主要div 来生成弹出窗口而不是ui-selectmenu。我已经坚持了一段时间了,如果有人可以帮助我解决这个问题,那将是一个很好的解脱