我正在使用下面链接中的 jquery-confirm 脚本。它能够在对话框中包含表单字段。您可以通过单击下面链接中的“按提示操作”蓝色按钮来查看此内容。
我已经设置了表单(单个字段),但我希望这个输入是一个日期选择器,并且我不知道应该在哪里放置 javascript 来实现这一点,因为在对话框出现之前此表单不存在被生成。
https://craftpip.github.io/jquery-confirm/ https://craftpip.github.io/jquery-confirm/
我的对话框 JavaScript:
$('.deal_edit').on('click', function () {
var id = $(this).attr('data-id');
$.confirm({
title: 'Change end Date',
content: 'url:form.txt',
confirm: function () {
var input = this.$b.find('input#new_end_date').val();
var errorText = this.$b.find('.text-danger');
if (input.val() == '') {
errorText.show();
return false;
} else {
var data = {action: 'edit_deal', id: id, new_date: new_date};
$.post('ajax.php', data, function(response) {
$.alert({
title: "Updated",
content: "Ok, record has been updated - this page will reload.",
confirm: function() {
location.reload();
}
});
});
}
}
});
return false;
});
form.txt的内容:
<p>The only editable field currently is 'deal end date'. (This may change soon)</p>
<div class="form-group">
<label>New End Date</label>
<input autofocus type="text" id="new_end_date" name="new_end_date" class="form-control">
</div>
<p class="text-danger" style="display:none">Please enter an end date, or click 'close'.</p>
谢谢你!!!