2014-05-19 6 views
0

다른 함수 onclick 이벤트 내에서 멋진 팝업을 표시하고 싶습니다. 이 함수에는 조건문이 있고 false이면 팝업이 표시되어야합니다. 나는 내가 뭘하려고 오전 보여줍니다 이는 jsfiddle을 만든다른 함수 내에서 magnificPopUp 호출

: http://jsfiddle.net/Lilu/heM4q/

HTML :

<button class="add-wishlist"><span>Wishlist</span></button> 

JQuery와 : 어떤 도움이 크게 감사합니다

$(document).on('click', '.add-wishlist', function(e) { 
    var yes = "1"; 

    if (yes == "2"){ 
     // Add to wishlist 
    }else { 
     // Display error in popup 
     $.magnificPopup.open({ 
      type: 'ajax', 
        alignTop: true, 
        mainClass: 'my-mfp-zoom-in', 
        removalDelay: 160, 
        callbacks: { 
         parseAjax: function(mfpResponse) { 
          mfpResponse.data = "<div class='modal-content'>"+"Sorry you cannot do that"+"</div>"; 
         }, 
         ajaxContentAdded: function() { 
          return this.content; 
         } 
        } 
     }); 

    } 

}); 

.

+0

http://jsfiddle.net/Lilu/heM4q/4/ 당신이 팝업 표시 얻을시겠습니까. –

+0

예. 그러나 그 진술이 거짓 일 때만. –

답변

0

아약스 대신 인라인 팝업을 사용하여 팝업을 얻을 수 있다는 것을 알았습니다.

HTML :

<button class="add-wishlist"><span>Wishlist</span></button> 

JQuery와 :

$(document).on('click', '.add-wishlist', function(e) { 
    var yes = "1"; 

    if (yes == "2"){ 
     // Add to wishlist 
    }else { 
     // Display error in popup 
     displayError(); 

    } 

}); 

function displayError() { 
     $.magnificPopup.open({ 
       items: { 
        src: '<div class="modal-content">' 
          +'<p class="error">' 
          +'<strong>Whoops!</strong></p>' 
          +'<p>You cannot do that.</p></div>', 

        type:'inline', 
       }, 
       closeBtnInside: true 
     }); 
} 

를 참조하십시오

관련 문제