开发者

Making a link confirmation with Jquery alert dialogs plugin

开发者 https://www.devze.com 2023-02-04 23:52 出处:网络
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).

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).

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'

JS Code:

<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)

HTML:

<a href="disable?action=disable&id=5" class="button red disable">Disable</a> Note: button repeated with different get vars

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 :<

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消