2011-05-04 5 views
1

안녕하세요 저는 jquery 오버레이를 사용하여 내 스크립트 처리가 끝났을 때 닫지 못하는 문제가 있습니다.jquery 오버레이가 닫히지 않습니다

내가하고있는 일은 매우 간단한 폼을 백그라운드에서 처리하고 페이지에 추가하는 것과 관련하여 제출하는 것입니다. 이 작업이 완료되면 오버레이가 닫히지 만 페이지가 새로 고침 될 때까지는 계속 진행되지 않습니다.

내 jQuery 코드는 다음과 같습니다 :이 코드의

function employmenthistory(){ 

    $(document).ready(function(){ 

     /** 
     * Modal Dialog Boxes Setup 
     */ 
     var triggers = $(".modalInput").overlay({ 

      // some mask tweaks suitable for modal dialogs 
      mask: { 
       color: '#ebecff', 
       loadSpeed: 200, 
       opacity: 0.7 
      }, 

      closeOnClick: false 
     }); 

     /* User Input Prompt Modal Box */ 
     $("#employmentprompt form").submit(function(e) { 

      // get user input 
      var name = $("#name", this).val(); 
      var role = $('#role', this).val(); 
      var title = $("#title", this).val(); 

      //we need to know how many elements already exist 
      var elementCount = $('li.note').length; 

      //update server with information about this employment 
      $.ajax({ 
       url: '/addempl/', 
       type : 'post', 
       data : "name=" + name + "&role=" + role + "&title=" + title + "&ec=" + elementCount, 
       dataType: "json", 
       success : function(msg){ 

        //confirm the event was successful 
        if(msg.status == 'success'){ 

         var item = msg.data; 

         //we now add to the ul for elements 
         $('ul.listing').append(item); 

        }else{ 

         //failed to process so display error 
         $('div.message error').html('<p>We were unable to add your employment history</p><p>Please try again</p>'); 
        } 
       }, 
       error : function(err){ 

        //failed to call server 
        $('div.message error').html('<p>We were unable to add your employment history</p><p>Please try again</p>'); 
       } 
      }); 

      // close the overlay 
      triggers.eq(0).overlay().close(); 

      // do not submit the form 
      return e.preventDefault(); 
     }); 
    }); 



} 

모든 측면이 페이지에 남아에서 내가

triggers.eq(0).overlay().close(); 

에 양식 오버레이를 얻을 때 따로 작동합니다. 호출 될 수있는 하나의 modelInput 요소와 폼만 있으므로 왜 이것이 실패하는지 잘 모르겠습니다. 이와

http://flowplayer.org/tools/demos/overlay/modal-dialog.html

어떤 도움을 기꺼이받을 것이다 :

내가했던 모든 여기에서 찾을 수있는 모범을 따를 것입니다.

감사합니다.

답변

1

오버레이 명령에 api 인수를 사용해야한다고 생각합니다. 나는 그들의 예에서 그것을 보지 못하지만, 나는 과거에 내 문제였던 것을 상기한다.

var triggers = $(".modalInput").overlay({ 

     // some mask tweaks suitable for modal dialogs 
     mask: { 
      color: '#ebecff', 
      loadSpeed: 200, 
      opacity: 0.7 
     }, 

     closeOnClick: false, 
     api: true 
    }); 

업데이트 여기

는 서로 모달 개방/폐쇄뿐만 아니라 개구 한 모달 나타내는 Working Demo이다. 희망이 도움이됩니다.

내가 현재 사용하고있는 코드 ... 양식의 제출/전체 페이지 새로 고침을 발생

var currentModal; 

function openModal(divName){ 
    closeModal(); 
    if ($('#' + divName).length>0){ 
     currentModal=$('#'+divName).overlay({ 
      mask: {color: '#000000'},  
      top:'0px', 
      api: true   
     }).load(); 
    } 
}  
function closeModal(){ 
    if (currentModal){ 
     if (currentModal.isOpened){ 
      currentModal.close(); 
     } 
    } 
} 
+0

슬프게이다. –

+0

작업 데모로 업데이트하십시오. – Dutchie432

관련 문제