jquery - Including Trent Richardson datetimepicker in asp.net mvc 3 application -


i need date-time picker 1 of views decided use trent richardson's one, seems popular choice. until can not make work , i'm not sure if i'm doing wrong or ok i'm missing steps.. maybe both. here did :

  1. added query code under name of jquery-ui-timepicker-addon in scripts\plugins\datepicker directory havejquery.ui.datepicker.min.js` have 2 filed there.
  2. include new js file in `shared_layout.cshtml view :

and these 2 steps made make datetimepicker available. in 1 of partial views use datepicker , works try use datetimepicker :

else if (field[i].mcs_fields.questiontypeid == 3)                     {                          <script type="text/javascript">                             $(function () {                                 $(".datetimepicker").datetimepicker();                             });                         </script>                         <input type="text" class="datetimepicker" />                         @*@html.textbox("datetimepicker", "", new { @class = "datetimepicker" })*@                     } 

but doesn't work. first tried @html.textbox can see commented , tried simple <input tag. in same partial view have :

if (field[i].mcs_fields.questiontypeid == 2)                     {                          <script type="text/javascript">                             $(function () {                                 $(".datepicker").datepicker();                             });                         </script>                         @html.textbox("datepicker", "", new { @class = "datepicker" })                     } 

and it's working expected. i've noticed in _layout page datepicker js files not included anywhere , still can use it. including datetimepicker in wrong place? or problem somewhere else?

in layout make sure have included jquery-ui-timepicker-addon.js script after jquery.ui.datepicker.min.js script must included after jquery.js script.

also recommend removing scripts partial , put after script inclusions in layout:

<script type="text/javascript">     $(function () {         $('.datetimepicker').datetimepicker();     }); </script> 

if scripts included @ end of dom don't need wrap them in document.ready event.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -