2016-11-16 1 views
0

내 코드는 다음과 같습니다정지 JQuery와 - UI를 날짜 선택기 확인 상자

HTML,

Date : <input id="datepicker"> 
Fare : <input id="fare"> 

JS,

<script> 
    $(function(){ 
     $("#datepicker").datepicker({ 
      changeMonth: true, 
      changeYear: true, 
      showAnim: 'clip', 
      dateFormat: "yy-mm-dd" 
     }).val(); 
    }); 


    $("#datepicker").click(function() { 
     if (confirm("If you change the Date the Fare fields data will be deleted !!")) { 
      $('#fare').val(''); 
     } else { 
      return false; 
      $("#datepicker").datepicker('destroy'); 
     } 
    }); 
<script> 

나는 내가 취소 할 때 날짜 선택기를 중지하는 것을 시도하고있다 확인 상자. Unfortunetly 그것의 작동하지 않습니다. 도와주세요.

답변

0

false를 반환하고 datepicker를 삭제합니다.

반대 여야합니다. 이 시도 :

$("#datepicker").click(function() { 
    if (confirm("If you change the Date the Fare fields data will be deleted !!")) { 

     $('#fare').val(''); 

    }else{ 
     $("#datepicker").datepicker('destroy'); 
     return false; 
    } 
}); 
0

먼저, 다음 return false을 파괴,

<script> 
$(function(){ 
    $("#datepicker").datepicker({ 
     changeMonth: true, 
     changeYear: true, 
     showAnim: 'clip', 
     dateFormat: "yy-mm-dd" 
    }).val(); 
}); 


$("#datepicker").click(function() { 
    if (confirm("If you change the Date the Fare fields data will be deleted !!")) { 
     $('#fare').val(''); 
    }else{ 
     $("#datepicker").datepicker('destroy'); 
     return false; 
    } 
}); 

관련 문제