2016-08-31 8 views
0

私はLaravel 4.2/PHPプロジェクトを持っています。このプロジェクトにはページロード時に表示されるモーダルと、フォームにdatetime pickerがあります。日付が現在の日付の30日以内にある場合は、警告ポップアップを表示したいと思います。 datepickerで何かをコーディングしようとすると、モーダル関数がなくなり、ピッカーが通常のものに戻ります。誰かが私にこれを解決する方法に関するいくつかの指導を与えることができますか?jquery datetimeピッカーの値に基づいてアラートを表示する方法は?

$('#myModal').modal('show'); 

    $('#ApplicationDeadline').datepicker({ 
     startDate: '1d', 
     endDate: '+365d', 
\\ code for alert goes here I assume? When I put code here it breaks the modal 

     }); 


    @if($Modal) 
     <!-- Modal --> 
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" > 
      <div class="modal-dialog"> 
       <div class="modal-content"> 
       <div class="modal-header"> 
        <button type="button" class="close" data-dismiss="modal"> 
         <span aria-hidden="true">&times;</span><span class="sr-only">Close</span> 
        </button> 
        <h4 class="modal-title">External Grant</h4> 
       </div> 
       <div class="modal-body"> 
        <p>The External Grant Pro Application needs to be discussed with Grant Administrator before submitting an application. </p> 
       </div> 
       <div class="modal-footer"> 

        <button type="button" class="btn btn-primary btn-lg pull-right" data-dismiss="modal">OK, Let's Begin</button> 
       </div> 
      </div> 
     </div> 
    </div> 
    @endif 

    {{ HTML::col(6,6,6,6) }} 
     {{ Form::formGroup() }} 
      {{ Form::label('ApplicationDeadline', 'Application Deadline Date') }} 
      {{ Form::date('ApplicationDeadline', '', array('class' => 'form-control')) }} 
     {{ Form::closeFormGroup() }} 
    {{ HTML::closeCol() }} 
+0

ただ、DatePickerの入力変更イベントでのDateDiff関数を実行しますか? – Jecoms

答えて

0

イベントリスナーのコールバックとして関数を呼び出す必要があります。 datepickerオブジェクトで変更イベントコールバックを指定する場合は、APIを参照する必要があります。さもなければ、単純なイベントリスナはjQueryを使ってうまくいきます。

jQueryの使用:

<script> 
... 
    $(function() { 
     $('#ApplicationDeadline').on('change', function(){ 
      // datediff/alert code here 
     }); 
    });  
... 
</script> 
関連する問題