2016-06-09 4 views
0

모달 안에 $("#modal").closeModal();을 호출하면 complete 메서드가 트리거되지 않습니다. 다음과 함께 모달을 엽니 다.Materialize closeModal이 완료되지 않음

$("#modal").openModal({ 
    dismissible: false, 
    complete: this.doSomething 
}); 

내가 잘못하고있는 것이 있습니까? 모달을 닫아 모달을 트리거하는 방법이있어서 complete 메서드가 트리거됩니까? 모달이 닫히기 전에 어떤 일이 일어날 때까지 기다려야합니다.

+0

방법이 Angular2 관련이가? 실제로 더 많은 문맥을 추가하십시오. Angular2에서 어디에서 어떻게 사용하고 있습니까? –

답변

1

이게 원하는가요?

html 파일

<!-- Modal Structure --> 
<a class="waves-effect waves-light btn modal-trigger" href="#modal1">Modal</a> 

<div id="modal1" class="modal"> 
    <div class="modal-content"> 

    <!--following line has the icon to close the modal on your command--> 

    <h4>Modal Header <i class = "material-icons right" id = "closeIcon">close</i></h4> 
    <p>A bunch of text</p> 

    <!--following button adds text to the <p> tag with id = "textBody" i.e. its doing something and the modal wont close until that is done--> 

    <button class = "btn waves-effect waves-light" id = "doSomething">Press me and do something</button> 


    </div> 
    <div class="modal-footer"> 
    <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a> 
    </div> 
</div> 
<p id = "textBody"> 

</p> 

JQuery와 여기

$(document).ready(function(){ 
    $('.modal-trigger').leanModal({ 
    dismissible: false, 

    /*waiting for the user to click the button before closing*/ 
    complete: $('#doSomething').click(function(){   

        $('#textBody').html('i got a Boo Boo'); 
        $('#modal1').closeModal();      

       })   

    }); 
    $("#closeIcon").click(function(){ 
    $('#modal1').closeModal(); 
    }); 



}) 

무슨 일이 일어나고 있는지 확인하는 링크입니다 : https://jsfiddle.net/4y6ptm8k/4/

+0

죄송합니다.이 백업을 미안하지만, closeModal을 호출하여 사용자 이벤트가 아닌 전체 이벤트를 발생시키는 방법이 있습니까? 나는 구글을 다 써 버렸고 해결책을 찾지 못했습니다. – IRCraziestTaxi

+0

@IRCraziestTaxi closeModal() 함수 안에서 이벤트를 발생 시키길 원합니까? – hulkinBrain

관련 문제