In our current app we are using kalendae datepicker plugin. Lately, we wanted to add a 'today' button that is visible to the user in all the datepicker popovers(used for numerous date fields throughout the app). As the name suggests on clicking this button, the current date gets selected and is displayed in the corresponding field.

Github link of kalendae - https://github.com/ChiperSoft/Kalendae

We can do this by writing function to add button in popup and then we can use it wherever we need.

function setTodaysDate(kalendae_popup){
  var inputToAdd = $("", {
    type : "button",
    id : "set_today_date",
    value : "Today"
  });
  var kalendae_popup = kalendae_popup.find('.kalendae');
  kalendae_popup.append("
"); kalendae_popup.append(inputToAdd); $("#set_today_date").live('click', function(){ today_date = Kalendae.moment(new Date()).format("MMM DD, YYYY"); $(this).closest('#kalendar').children().attr('value', today_date).blur(); }); }

In above code we need to pass kalendae's form element as parameter to the setTodaysDate function..