[英]Making a link confirmation with Jquery alert dialogs plugin
I have the following situation: 我有以下情况:
-A website with a table where every row represents an item, and for each item there is a link to make certain action (with GET vars). -一个带有表格的网站,其中每一行代表一个项目,并且每个项目都有一个链接,可以进行某些操作(使用GET vars)。
So, I'm using the Jquery Alert Dialogs Plugin for making a confirmation message, but i can't get to follow the link after the user presses 'OK' 因此,我正在使用“ jQuery警报对话框”插件发出确认消息,但是在用户按下“确定”后,我无法跟随链接
JS Code: JS代码:
<script type="text/javascript">
var go = false;
$(document).ready( function() {
$("a.disable ").click( function() {
if(go == false) {
jConfirm('Are u sure?', 'Confirm action', function(r) {
if (r == true)
{
go = true;
alert( $(this).attr['href']);
}
});
});
</script>
Note: I'm using alert for testing, but that should be a document.location Note 1: the alert() gives me 'undefined' :( Note 2: I'm using multiple buttons with the same class (number of buttons depends on items count) 注意:我正在使用Alert进行测试,但是应该是一个document.location注意1:1:alert()给我'undefined':(注意2:我正在使用同一个类的多个按钮(按钮的数量取决于数量)
HTML: HTML:
<a href="disable?action=disable&id=5" class="button red disable">Disable</a>
Note: button repeated with different get vars <a href="disable?action=disable&id=5" class="button red disable">Disable</a>
注意:按钮重复使用不同的get var
Also, if I use "a.disable" selector in the alert(), I got the URL of the first button in the page, so doesn't work :< 另外,如果我在alert()中使用“ a.disable”选择器,则会获得页面中第一个按钮的URL,因此不起作用:<
Thanks! 谢谢!
<script type="text/javascript">
var go = false;
$(document).ready( function() {
$("a.disable").click( function() {
var $this = $(this); // cached the object $(this)
if(go == false) {
jConfirm('Are u sure?', 'Confirm action', function(r) {
if (r == true)
{
go = true;
alert( $this.attr('href')); // use the cached object
}
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.