需要帮助!我试图在onclick事件后在模态窗口中打开MWO表单(../forms/mwo.php)。当我点击按钮时,我什么都没得到......甚至没有错误。
<a id="newMWO" name="newMWO" data-role="button" data-inline="true" target="_blank" onclick=getWOCnt()>
New Work Order
</a>
<div id="mwoForm" title="MWO Form"></div>
$(function ()
{
$(".newMWO").on('click', (function (event)
{
event.preventDefault();
var loadVars=(encodeURI("../forms/MWO.php?a=<?php echo $_REQUEST['a']?>"));
var dialogName= $("#mwoForm").load(loadLVars);
$(dialogName).dialog({
autoOpen: false,
resizable: true,
modal: true,
bigframe: true,
height: 600,
width: 1000,
overflow: scroll,
resizable: true,
title: "MWO New Work Order"
});
dialogName.dialog('open');
return false;
}));
});
答案 0 :(得分:1)
在#
.
代替anchor tag selector
代替$("#newMWO")
$(".newMWO")
或将class
添加到您的anchor tag
<a id="newMWO" name="newMWO" class="newMWO" data-role="button"
data-inline="true" target="_blank" onclick=getWOCnt()>
New Work Order
</a>
答案 1 :(得分:0)
您的选择器$(".newMWO")
错误,应该是$("#newMWO")
。 newMWO
不是类属性值,它是元素的ID,因此您需要使用id-selector而不是class-selector
$(function() {
$(".newMWO").on('click', function(event) {
event.preventDefault();
var loadVars = (encodeURI("../forms/MWO.php?a=<?php echo $_REQUEST['a']?>"));
var dialogName = $("#mwoForm").load(loadLVars);
$(dialogName).dialog({
autoOpen : false,
resizable : true,
modal : true,
bigframe : true,
height : 600,
width : 1000,
overflow : scroll,
resizable : true,
title : "MWO New Work Order"
});
dialogName.dialog('open');
return false;
});
});