gpt4 book ai didi

javascript - 在按钮单击事件上关闭模式对话框

转载 作者:行者123 更新时间:2023-12-01 02:00:33 25 4
gpt4 key购买 nike

我有一个模式窗口,单击下拉列表中的项目即可打开。 我陷入了通过点击按钮来关闭对话框的困境。

 var $that = this;
$("#btncart_cancel").on("click", function () {
///// ***********close the dialog ***************
/// tried this but not working
$that.dialog("close");
});

我的代码:

$(".ddlCart li").click(function (e) {
$('#actionsCart').slideToggle();

var ddlselectedVal = $(this).attr('id');
var selectedListinsCount = selected_Listings.length;
var SelectedMlsnums = selected_Listings.join();
var agentId = $("#AgentId").val();

var EnvironmentURL = $("#EnvironmentURL").val();

var autoUrl = "/Stats/SearchContacts";
var Action = "PreAddToCart"

var postData = {
AgentId: agentId,
Mlsnums: SelectedMlsnums,
ActionTypeValue: Action
};
var $that = this;
var close = function (event, ui) {
$(this).dialog("destroy");
}
var open = function (event, ui) {
var agentId = $("#AgentId").val();
var url = EnvironmentURL + "/Stats/SearchContacts";

$("#btncart_cancel").on("click", function () {
///// ***********close the dialog ***************
});

$("#btncart_submit").on("click", function () {
$(".liloading").show();

if (App.ContactInfo.Id != 'undefined') {
var contactKey = App.ContactInfo.Id;
var cartName = App.ContactInfo.Name;
} else {
var contactKey = 0;
var cartName = 'My Personal Cart';
}

var note = $("#txtNotes").val();
var url = EnvironmentURL + "/Stats/Cart";

//Send the data using post and put the results in a div
$.post(url, {
CartName: cartName,
Notes: note,
Contactkey: contactKey,
ActionTypeValue: "AddToCart"
},

function (data) {
// Replace current data with data from the ajax call to the div.
$("#dvModalDialog").empty().append(data);

});
});
};

var rd = Mod.ReportsDialog({
title: 'Add To Cart',
close: close,
open: open
});
rd.url = EnvironmentURL + "/Stats/Cart";
rd.targetElement = '#dvModalDialog' // '#dvSendEmail'
rd.formName = '#frmCart'
rd.postData = postData
rd.open();
var $that = this;
});

最佳答案

我在 close 方法中看到的问题是 $that 不是 JQuery 对象。

您可以使用 $($that).dialog("close")$(this).dialog("close")$('#dvModalDialog').dialog("close").

关于javascript - 在按钮单击事件上关闭模式对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24170435/

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