• Disclaimer

Developer Concepts

DatePicker with dynamic DOM Elements

May 17, 2012 10:44 am / Steve

I have been battling with a problem with the date picker. The problem is that when I add new inputs with the DatePicker class they do not behave in the same way as with the document load. The code I was using was:

$(document).ready(function (){
     $("input.datePicker").datepicker();
});

After that I was just trying to rebind the events using the destroy and datepicker methods.  Unfortunately this did not work!  Eventually I found this great stackoverflow answer and since I was cloning the elemtns I had to remove the hasDatePicker to rebind.

$('.date').last().removeClass('hasDatepicker');
$('.date').last().removeAttr('id');
$('.date').last().datepicker();

Hopefully this helps if you have the same problem.

Posted in: Javascript, Jquery / Tagged: DatePicker, Javascript, jquery

Comments are closed.

Post Navigation

← Previous Post
Next Post →

Recent Posts

  • Unrecognized element folderLevelBuildProviders
  • Using Javascript to Load Blog Posts From WordPress
  • An introduction to KnockoutJS Observables
  • Automating NTLM logins with Selenium
  • KnockoutJS and Web API

Recent Comments

    Archives

    • July 2015
    • April 2015
    • March 2015
    • November 2014
    • October 2014
    • June 2014
    • May 2014
    • March 2014
    • February 2014
    • November 2013
    • August 2013
    • January 2013
    • November 2012
    • May 2012
    • September 2011
    • July 2011
    • May 2011
    • March 2011
    • November 2010
    • September 2010
    • February 2010
    • December 2009
    • November 2009
    • October 2009

    Categories

    • Architecture
    • Caching
    • Code Smells
    • Html 5
    • IOC
    • Javascript
    • Jquery
    • JSON
    • KnockoutJS
    • Linq
    • Linq To Xml
    • Mocking
    • MVC
    • MVVM
    • MySql
    • NHibernate
    • Selenium
    • Silverlight
    • Solving Errors
    • Sql
    • TDD
    • Uncategorized
    • Unit Testing
    • Visual Studio 2010
    • WCF

    Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
    © Copyright 2019 - Developer Concepts
    Infinity Theme by DesignCoral / WordPress