gpt4 book ai didi

javascript - jQuery 确认对话框中的 jQuery UI 日期选择器

转载 作者:行者123 更新时间:2023-11-30 00:05:56 26 4
gpt4 key购买 nike

我正在使用以下链接中的 jquery-confirm 脚本。它能够在对话框中包含一个表单域。您可以通过单击下面链接中的“像提示一样操作”蓝色按钮来查看。

我已经设置了表单(单个字段),但我希望这个输入是一个日期选择器,而且我不知道我应该把 javascript 放在哪里才能实现这一点,因为这个表单不存在直到对话框生成。

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>

谢谢!!!

最佳答案

我遇到了同样的问题,我就是这样解决的。

需要在确认对话框中添加onOpen和onClose事件才能添加

        $.confirm({
onOpen: function(){
$( ".datepicker" ).datepicker();
},
onClose: function(){
$(".datepicker").datepicker("destroy");
},
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();
}
});

});
}
}
});

关于javascript - jQuery 确认对话框中的 jQuery UI 日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38570375/

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