我的问题是我设计了一个用于过滤按钮的弹出窗口。当弹出窗口打开时,有单击按钮的过滤器关闭过滤器弹出窗口并执行处理。问题从这里开始。当我再次点击弹出按钮和okey过滤器,进程完成2次并弹出关闭,当我再次过滤时,弹出3次并关闭,但每次过滤必须只有一次。代码如下;
console.log("girdi");
$('[data-toggle="popover"]').popover({
trigger: 'click',
html: 'true',
content: '<textarea class="popover-textarea"></textarea>',
template: '<div class="popover"style="width:450px;height:250px;">' +
'<div class="arrow">' +
'</div>'+
'<div style="width:100%;height:100%;">' +
'<div style="width:80%;margin-top:20px;margin-left:10%;background:#eee;height:30px;border-radius:5px;border:3px solid #eee">' +
'<a href="#" id="customDate" class="clicked" style="width:33%;height:100%;float:left;text-align:center;padding-top:3px;border-radius:3px;">Range</a>' +
'<a href="#" id="dayChoose" class="" style="width:33%;height:100%;float:left;text-align:center;padding-top:3px;border-radius:3px;">Days</a>' +
'<a href="#" id="phoneChoose" class="" style="width:33%;height:100%;float:left;text-align:center;padding-top:3px;border-radius:3px;">Phone</a>' +
'</div>' +
'<div style="width:80%;margin-top:20px;margin-left:10%;height:120px;">' +
'<div style="width:100%;height:100%;display:block"class="customArea area">' +
'<form>' +
'<div class="radio">' +
'<label><input class="customType" type="radio"style="color:grey" name="optradio"value="0">None</label>' +
' </div>' +
'<div class="radio">'+
'<label><input class="customType" type="radio"style="color:grey"checked="checked" name="optradio"value="1">Today</label>' +
' </div>' +
'<div class="radio">' +
' <label><input class="customType" type="radio"style="color:grey" name="optradio"value="2">Week</label>' +
'</div>' +
'<div class="radio">' +
' <label><input class="customType" type="radio"style="color:grey" name="optradio"value="3">Month</label>' +
'</div>' +
'</form>' +
'</div>' +
'<div style="width:100%;height:100%;display:none"class="dateArea area">' +
'<div class="input-group date">' +
'<input type="date"class="form-control"id="dateSpe"placeholder="DD.MM.YYYY" value="">' +
'<div class="input-group-addon">' +
'<span class="glyphicon glyphicon-th"></span>' +
'</div>' +
'</div>' +
'</div>' +
'<div style="width:100%;height:100%;display:none"class="phoneArea area">' +
'<div class="input-group date">' +
'<input type="text"class="form-control"id="phone"placeholder="Phone" value="">' +
'<div class="input-group-addon">' +
'<span class="glyphicon glyphicon-earphone"></span>' +
'</div>' +
'</div>' +
'</div>' +
'<input type="button" value="Listele"id="reportGet" style="width:100%;height:30px;background:darkcyan;border-radius:5px;color:white">' +
'</div>' +
'</div>'
}).on('shown', function () {
console.log("girdi");
$("#reportGet").click(function () {
var startDate = "";
var endDate = "";
var phone = "";
var customChoose = document.querySelector('input[name="optradio"]:checked').value;
var speDate = $("#dateSpe").val();
var phone = $("#phone").val();
if (customChoose != "0" && speDate != "") {
//alert("İki farklı tarih filtresi girilemez");
new PNotify({
title: "Mobil Eğitim",
type: "warning",
text: "İki farklı tarih filtresi girilemez",
styling: 'bootstrap3',
hide: true, delay: 3000,
before_close: function (PNotify) {
PNotify.update({
title: PNotify.options.title + " - Enjoy your Stay",
before_close: null
});
PNotify.queueRemove();
return false;
}
});
//$('[data-toggle="popover"]').popover('hide');
return;
}
if (customChoose == "0" && speDate == "" && phone == "") {
//alert("En az bir filtre girmelisiniz");
new PNotify({
title: "Mobil Eğitim",
type: "warning",
text: "En az bir filtre girmelisiniz",
styling: 'bootstrap3',
hide: true, delay: 3000,
before_close: function (PNotify) {
PNotify.update({
title: PNotify.options.title + " - Enjoy your Stay",
before_close: null
});
PNotify.queueRemove();
return false;
}
});
//$('[data-toggle="popover"]').popover('hide');
return;
}
if (customChoose == "0" && speDate == "") {
startDate = '01.01.1990';
endDate = todayDate();
$("#dateInput").val(phone);
}
if (speDate != "") {
speDate = speDate.substring(8, 10) + "." + speDate.substring(5, 7) + "." + speDate.substring(0, 4);
startDate = speDate
endDate = speDate;
$("#dateInput").val(speDate);
}
if (customChoose == "1") {
startDate = todayDate();
endDate = todayDate();
$("#dateInput").val("@Html.Raw(Resources.Resource.value_today)");
}
if (customChoose == "2") {
startDate = weekDate();
endDate = todayDate();
$("#dateInput").val("@Html.Raw(Resources.Resource.value_week)");
}
if (customChoose == "3") {
startDate = monthDate();
endDate = todayDate();
$("#dateInput").val("@Html.Raw(Resources.Resource.value_month)");
}
getReport(startDate, endDate, phone);
$('[data-toggle="popover"]').popover('hide');
return;
});
$("#customDate").click(function () {
$("#customDate").addClass("clicked");
$("#dayChoose").removeClass("clicked");
$("#phoneChoose").removeClass("clicked");
$(".area").hide();
$(".customArea").show();
});
$("#dayChoose").click(function () {
$("#customDate").removeClass("clicked");
$("#dayChoose").addClass("clicked");
$("#phoneChoose").removeClass("clicked");
$(".area").hide();
$(".dateArea").show();
});
$("#phoneChoose").click(function () {
$("#customDate").removeClass("clicked");
$("#dayChoose").removeClass("clicked");
$("#phoneChoose").addClass("clicked");
$(".area").hide();
$(".phoneArea").show();
});
});