jQuery的确认 - 如何发送HREF链接到浏览器
我使用这个漂亮的jQuery插件,确认v3.0.3(http://craftpip.github.io/jquery-confirm/)确认动作jQuery的确认 - 如何发送HREF链接到浏览器
但是,使用下面的代码,从HREF行动时,我当我按OK按钮时链接没有执行?
我做错了什么?感谢您的帮助......
<a class="delItem" href="?del=true&id=1">Supprimer</a>
$('a.delItem').confirm({
title: 'Confirmer cette action',
content: '',
animation: 'left',
theme: 'light',
type: 'red',
autoClose: 'cancel|10000',
buttons: {
confirm: {
text: 'OK'
},
cancel: {
text: 'Annuler',
action: function() {
//$.alert('action is canceled');
}
}
}
});
你有没有尝试添加
location.href = this.$target.attr('href');
在您确定按钮像
$('a.delItem').confirm({
title: 'Confirmer cette action',
content: '',
animation: 'left',
theme: 'light',
type: 'red',
autoClose: 'cancel|10000',
buttons: {
confirm: {
text: 'OK',
location.href = this.$target.attr('href')
},
cancel: {
text: 'Annuler',
action: function() {
//$.alert('action is canceled');
}
}
}
});
感谢您使用location.href = this。$ target.attr('href'); 但是,如果我想通过POST请求? 在jquery的最后一个版本中,确认它可以不需要location.href = this。$ target.attr('href'); – Chris
@Chris我从来没有使用'jquery-confirm',但似乎你可以使用“正常”'ajax'请求https://craftpip.github.io/jquery-confirm/#content-loaded所以只需设置方法和数据像这里解释:http://api.jquery.com/jquery.ajax/#entry-examples – caramba
谢谢。只是这个插件的版本2在POST请求之前保留了。我现在要使用$ .ajax方法;)) – Chris
如果您的确认按钮有一个ñ行动设置为它? – Sami