2013-02-11 1 views
2

팝업 컬러 박스에 폼이 있고 사용자가 텍스트 박스 중 하나를 편집 한 다음 취소를 누르면 뭔가 표시되는 팝업이 나타납니다 "저축하지 않고 떠나시겠습니까?" 현재 내가 팝업이 표시했지만 팝업 colorbox 이미 사용자 페이지의add "저장하지 않고 페이지를 저장하고 싶습니까?"colorbox 팝업으로 폼에

표를 닫은 후이 표시되어

$('a.openDialog').colorbox({ 
       iframe: true, 
       transition: "elastic", 
       width: "75%", height: "90%" 
      }); 

실제 양식 페이지 당신은 콜백을 colorbox 사용할 수 있습니다

$(':input', 'form').bind("change", function() { 
       setConfirmUnload(true); 
      }); 


function setConfirmUnload(on) { 

       window.onbeforeunload = (on) ? unloadMessage : null; 
      } 

      function unloadMessage() { 
       return 'You have entered new data on this page.' + 
     ' If you navigate away from this page without' + 
     ' first saving your data, the changes will be' + 
     ' lost.'; 
     } 

답변

2

onCleanup 또는으로 onClose 그게 닫기 버튼이나 div에 수신기를 추가 할 수없는 경우

0

해결책을 찾았다면 colorbox의 oncomplete 함수를 호출해야합니다. 코드

$("#cboxClose").click(function (e) { 

         // stop any other script from firing 
         e.stopPropagation(); 

         if (confirm('You have unsaved changes, are you sure that you want to cancel? All of your changes will be lost.')) { 
          $.colorbox.close(); 
          // ensure that the binding is removed when closed 
          $("#cboxClose").unbind(); 
         } 

        }); 

       } // close oncomplete