0

I build a date picker object, that called Calender the object have fews parameters like

this.StartDate //The min date of the calendar
this.EndDate  //The max date of the calendar
this.FromDate //Selected start date
this.ToDate //Selected end date

and a function called this.create() that bind a <table> element with the days of some month

every <td> contain date, and the attribute of the <td> is class="date_click" and data-date="**the date string**"

I built a simple function called this.date_pick, that update the variable this.FromDate by clicking the <td> elements

the code:

   this.date_pick=function(e)
   {
      this.FromDate=new Date(this.getAttribute("data-date"));
      console.log(this.FromDate);
      this.create();
   };

   var items = document.getElementsByClassName('date_click');
   for (var i = 0; i < items.length; i++) {
     items[i].addEventListener('click', this.date_pick);
   }

The function update the variable this.FromDate, but not executes the create() fuction. the error:

Uncaught TypeError: this.create is not a function
    at HTMLTableCellElement.Calendar.date_pick

What can i do to make the create function executes? thanks for the helpers

0 Answers0