ruby on rails - Bootstrap datepicker is appending one by one for 2 fields at a time -


in rails 3.2.9, using bootstrap's datepicker display date. in single form, need display datepicker 2 fields. if click first field datepicker popup. after if click 'tab' button popup second field's datepicker appending first datepicker. need display 1 datepicker @ time particular field's onclick. if click 'tab' button first field's datepicker should hidden , second field's datepicker should popup.

javascript below

function currentdatepicker(id){ var nowtemp = new date(); var = new date(nowtemp.getfullyear(), nowtemp.getmonth(), nowtemp.getdate(), 0, 0, 0, 0);  $('#' + id).datepicker({     format: "yyyy-mm-dd",     onrender: function(date) {         return date.valueof() < now.valueof() ? 'disabled' : '';     } }); 

}

in views,

<%= f.input :start_date, :as=>:string, :label =>"start date", :required => false,   :input_html=>{:readonly=>true, :value=>@user.start_date.blank? ? "" : @user.start_date} %>  <%= f.input :end_date, :as=>:string, :label =>"end date", :required =>false,   :input_html=>{:readonly=>true, :value=>@user.end_date.blank? ? "" : @user.end_date} %>  <script type="text/javascript">  currentdatepicker('user_start_date');  currentdatepicker('user_end_date'); </script> 

for more information have added image

above have added image more information. please me solve issue.

you can use different ids date picker , use event handling on ids. hide manualy first datepicker when clicked on 2nd datepicker. or use autoclose attribute of datepicker. $('#from').datepicker( { autoclose: true, startdate: today.getdate.tostring() } ); $('#to').datepicker( { autoclose: true, startdate: today.getdate.tostring() });

form , #to ids.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -