title: jQuery datepicker not working - Laravel app
body: <p>I contained my datepicker input inside if statement, so it doesn't work. I don't know whether it isn't working because of if statement or else, but when there is no if statement, datepicker works fine. Scripts are included in right order, so that is fine.
  jQuery scripts:</p>
  
  <pre><code>&lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;script&gt;
   $(function() {   
   $('#nextDate').datepicker({
      dateFormat: "yy-mm-dd", 
      });
      $("#currentDate").datepicker({
      dateFormat: "yy-mm-dd", 
      minDate:  0,
      onSelect: function(date){
          var date2 = $('#currentDate').datepicker('getDate');
          date2.setDate(date2.getDate()+7);
          $('#nextDate').datepicker('setDate', date2);
          }
      });
   });
   &lt;/script&gt;
  </code></pre>
  
  <p>The page where datepicker should be, stands like this:</p>
  
  <pre><code>if(Auth::user()-&gt;role == 2) { ?&gt;
  &lt;form class="form-horizontal" method="POST" action="/rentals"&gt;
  {{ csrf_field() }}
      &lt;div class="form-group"&gt;
              &lt;div class="col-sm-5 col-sm-offset-1"&gt;
                  &lt;input class="form-control" type="text" id="currentDate" name="start"&gt;
              &lt;/div&gt;
              &lt;div class="col-sm-5"&gt;
              &lt;input class="form-control" type="text" id="nextDate" name="end"&gt;
              &lt;/div&gt;
      &lt;/div&gt;
          &lt;button type="submit" class="btn btn-success"&gt;Rent it&lt;/button&gt;
          &lt;/form&gt;
   &lt;?php } ?&gt;
  </code></pre>