我查找了类似的问题,但是这些解决方案与嵌套在其他点击事件中的点击事件有关,因此它们被覆盖了。
我的代码是:
pdf format
因此,UI以displayCurrentPlan()开始。如果我在该PDF formtat
UI内单击该按钮,它将调用int count = 0;
foreach (HttpPostedFileBase file in emailasign.Files)
{
var filename = "";
//Checking file is available to save.
if (file != null)
{
var random = new Random();
filename = random.Next(111111, 999999).ToString() + Path.GetExtension(file.FileName);
var ServerSavePath = Path.Combine(Server.MapPath("~/UploadedFiles/") + filename);
//Save file to server folder
file.SaveAs(ServerSavePath);
count++;
}
if (count > 1)
{
TempData["OrignalFile"] += "," + file.FileName;
TempData["FileName"] += "," + filename;
}
else if (count == 1)
{
TempData["OrignalFile"] = file.FileName;
TempData["FileName"] = filename;
}
}
并呈现该UI。在该UI中,我想伪造回去的体验,并将click事件附加到箭头上,然后再次调用 function choosePlan() {
console.log("ASD");
$('.no-sub-container').remove();
let arrow = `
<img src="{{ 'arrow.png' | asset_url }}" id="arrow">
`
$('.title').append(arrow);
let arrowImg = document.getElementById('arrow');
arrowImg.addEventListener("click", displayCurrentPlan, true);
};
function displayCurrentPlan() {
console.log("displayCurrentPlan");
let noPlanBody = `
<div class="no-sub-container">
<div class="no-subscription">
Choose Plan
</div>
<button class="submit" id="select-plan">SELECT A PLAN</button>
</div>
`
$('.account-container').append(noPlanBody);
// progress to next step of choosing plan on click
let selectPlan = document.getElementById('select-plan');
selectPlan.addEventListener("click", choosePlan, true);
};
displayCurrentPlan();
,从而渲染第一个屏幕。但是,这只能工作3次。我可以从屏幕1->屏幕2-屏幕1->屏幕2 ...中去,但是该屏幕上的箭头(choosePlan)对单击没有响应。