好的,所以我打开一个用户需要确认交易的Modal,每当我让用户点击HTML页面上的按钮时,一切似乎都很好,但每当我让它们点击Modal内部时它不断回来,不接受交易。 (我正在使用TingleJS作为模态)
因此,它会触发失败代码而不是成功代码,但是当在html页面上执行时,它会触发成功代码。
任何?
这是代码:
$(document).on("click", "#confirmButton", function() {
toastSuccess("<div style='font-size:14px;'>Checking offer..</div>");
$this = $(this);
$this.prop("disabled", true);
var tid = $this.data("tid");
$.ajax({
url: "/confirm",
type: "GET",
data: {
"tid": tid
},
success: function(data) {
console.log(data);
try {
data = JSON.parse(data);
if (data.success) {
if (data.action == "accept") {
toastSuccess("<div style='font-size:14px;'>" + data.result + "</div>");
} else {
toastError("<div style='font-size:14px;'>" + data.result + "</div>");
}
$("#offerPanel").slideUp();
} else {
toastError("<div style='font-size:14px;'>" + data.error + "</div>");
if (data.count > 0) {
cmdm();
}
}
} catch (err) {
inlineAlert("error", "Javascript error: " + err);
}
},
error: function(err) {
inlineAlert("error", "AJAX error: " + err.statusText);
},
complete: function() {
$this.prop("disabled", false);
}
});
return false;
});
这样在页面上执行得很好(一切正常):
<button class="" id="confirmButton" data-tid="0">Confirm</button>
它会触发onclick id,但在接受交易时它不会返回成功:
var pendingModal;
function showPendingModal(data) {
pendingModal = new tingle.modal({
footer: false,
stickyFooter: false,
cssClass: ['custom-class-1', 'custom-class-2']
});
var content = "<div style='text-align:center;font-size:25px;letter-spacing:2px;color:#379639;'>Success!</div>";
content+= "<div style='font-size:12px;letter-spacing:1px;text-align:center;color:#2B2E32;margin-bottom:25px;'>You've received an offer from our bot <b>" + data.bot + "</b></div>";
content+= "<div class='input-box' style='width:35%;background:#e8e8e8;margin:auto;padding-top:12px;padding-bottom:5px;padding-left:6px;padding-right:6px;'><div style='font-size:12px;letter-spacing:4px;text-align:center;color:#2B2E32'>Security Code</div><div style='font-size:2em;color:black;text-align:center;'>" + data.code + "</div></div>";
content+= "<div style='margin-top:30px;text-align:center;'><a style='background:#1E1E26;padding:9px 25px 9px 25px;border-radius:35px;color:white;letter-spacing:1px;font-size:25px;' href='https://steamcommunity.com/tradeoffer/" + data.tid + "' target='_blank'>Offer</a>";
content+= "<a style='margin-left:5px;background:#1E1E26;padding:9px 25px 9px 25px;border-radius:35px;color:white;letter-spacing:1px;font-size:25px;' id='confirmButton' data-tid='0'>Claim</a></div>"
pendingModal.setContent(content);
pendingModal.open();
}