我有ajax.actionlink
@Ajax.ActionLink("Click here",//link text
"Insert", // action name
"Projects", // controller
new { poz = item.itemID.ToString() }, // route values
new AjaxOptions() { HttpMethod = "GET", UpdateTargetID = "PrjDiv" OnSuccess = "Initiate_Dialog" }, // ajax options
new { @class = "openDialog", @id = item.idemID.ToString() } //htmlAttributes
)
和jQuery UI对话框
function Initiate_Dialog() {
var itemID= $(this).attr("id").replace("item_", "");
var prjID= $("#m_project").val();
var url = encodeURI("/Projects/Insert?poz=" + itemID+ "&proj=" + prjID);
$("#dialog-edit").dialog({
title: 'Insert',
autoOpen: false,
resizable: false,
height: 'auto',
width: 650,
show: { effect: 'drop', direction: "up" },
modal: true,
draggable: true,
open: function (event, ui) {
$(this).load(url);
},
close: function (event, ui) {
$(this).dialog('close');
},
buttons: {
Cancel: function () {
$(this).dialog("close");
}
}
});
$("#dialog-edit").dialog('open');
return false;
}
当我点击生成的链接时,我的控制器动作执行了2次。一旦使用从ajax.actionlink发送的参数,第二次使用从javascript发送的参数。
我知道我有2个电话,这就是为什么行动被执行了两次。我的问题是,有没有办法只执行来自javascript的调用,而不是来自actionlink?