jeudi 30 juin 2016

Visual Studio 2013 MVC - jquery datepicker

I have just begun to create an application in Visual Studio 2013 using MVC. I am trying to use jquery datapicker. I want it to show a datepicker where ever there is a DateTime field. I am creating my controllers using scaffolding (templates).

  1. I have imported the JQuery UI (combined Library).
  2. In the BundleConfig.css I added "~/Content/themes/base/all.css" to the bundles.Add(new StyleBundle("~/Content/css").Include
  3. Additionally added a new bundle --

    bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
           "~/Scripts/jquery-ui-{version}.js));
    
  4. In the _Layout.cshtml I added 2 new Scripts.Render

    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/Scripts/AQB_MON.js")
    
  5. I created my AQB_MON.js with the following

    $(document).ready(function(){
       $(".input[type='datetime']").each(function(){
        $(this).datepicker();
       });
    })
    

All seems to have no affect on any datetime field. Is this due to using scaffolding to create my Controllers/Views? As I was trying to use ToShortDateString() when displaying my datetime fields and came across an issue due to having scaffolding build them.

Aucun commentaire:

Enregistrer un commentaire