0

我有以下代码:

<div class="hidden">
  <div id="deletePopContent" class="c-popup">
    <h2 class="c-popup-header">Delete Practice Sheet</h2>
    <div class="c-content">         
      <h3>Are you sure to delete this practice sheet?</h3>
      <p class="alert"><strong>You are about to perform an action which can't be undone</strong></p>
      <a href="#"class="c-btn">No</a><a href="#"class="c-btn" id="delete_url">Delete</a> 
    </div>
  </div>
</div>

$(document).ready(function(){ 
$(document).on('click', '.edit_user_transaction_status', function (e) { 

    e.preventDefault();

      $.colorbox.close();

     //for confirmation that status change
    var ans=confirm("Are you sure to change status?");
    if(!ans) {
        return false;
    }

    var post_url           = $(this).attr('value');
    var transaction_status_update = $('#transaction_status_update').val();     

    $.ajax({
      type: "POST",
      url: post_url+"&transaction_status_update="+transaction_status_update,
      data:$('#transaction_form').serialize(),
      dataType: 'json',  
      success: function(data) {           
        var error = data.login_error;

        $(".ui-widget-content").dialog("close");
        //This variables use for display title and success massage of transaction update          
      var dialog_title   = data.title;              
      var dialog_message = data.success_massage; 
      //This get link where want to rerdirect
      var redirect_link  = data.href;       
      alert(redirect_link);
      /*var $dialog = $("<div class='ui-state-success'></div>")
                    .html("<p class='ui-state-error-success'>"+dialog_message+"</p>")
                    .dialog({
                  autoOpen: false,
                  modal:true,
                  title: dialog_title,
                  width: 500,
                  height: 80,
        close:  function(){                   
        document.location.href =redirect_link;

        }        
        });*/         
          /*$dialog.dialog('open');*/ 
          document.location.href =redirect_link;
          $.colorbox({inline:true, width:666});

         }          
      });
   });
});
4

1 回答 1

2

您需要使用href属性,例如:

$.colorbox({
   inline:true, 
   href: "#deletePopContent",
   width:666
});

您正在通过以下方式重定向:

document.location.href =redirect_link; <-- remove this
$.colorbox({inline:true, width:666, href: "#deletePopContent"});

所以只需删除它,它应该可以工作

您可以使用onClosedcolorbox 事件,以便在关闭 colorbpx 弹出窗口后重定向,例如:

$.colorbox({
    inline:true, 
    href: "#deletePopContent",
    width:666,
    onClosed: function() {
       window.location.href = redirect_link;
    }
});
于 2013-09-23T05:57:59.730 回答