2013-09-23 1 views
0

나는 다음과 같은 코드를 보내고 있습니다 :특정 ID 또는 클래스가있는 colorbox를 여는 방법은 무엇입니까?

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

당신처럼, href 속성을 사용할 필요가
$(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}); 

     }   
     }); 
    }); 
}); 

답변

2

:

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

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

당신이 리디렉션

그래서 그냥이를 제거하고 당신이 좋아하는 colorbpx 팝업을 닫은 후 재 있도록

당신이 colorbox의 onClosed 이벤트를 사용할 수 있습니다 작동합니다 :

$.colorbox({ 
    inline:true, 
    href: "#deletePopContent", 
    width:666, 
    onClosed: function() { 
     window.location.href = redirect_link; 
    } 
}); 
+0

: 귀하의 트릭 확실히 나를 위해 일했다. 그러나 이제 새로운 이슈가 생겨났습니다. 팝업은 1 초 이내에 자동으로 닫히고 닫힙니다. 사용자가 닫기 버튼을 클릭 할 때까지 colorbox 팝업이 있어야하므로이 문제에 대한 해결책을 제공해 줄 수 있습니까? – PHPLover

+0

@JSLover 내 대답을 참조하십시오 .. 그것이 도움이되기를 바랍니다 –

+0

: 고마워,이 트릭도 나를 위해 일했다. 그러나 이제는 하나의 작은 문제가 여전히 남아 있습니다. 변수 redirect_link에 포함 된 URL을 어떻게 열어야합니까? 업데이트가 완료된 후 해당 URL의 페이지로 URL을 리디렉션하고 싶습니다. colorbox 팝업은 실제로 성공 메시지 만 표시하기위한 것입니다. – PHPLover