Calendar Class in Javascript - unable to keep the reference. -


i wrote datepicker in javascript, not working properly,

as lose reference calendar object.

here example

http://asexpress.de/calendar/

by clicking within input field calendar displayed.

what should reference calendar object remains in contact.

from can tell far of script, following code block:

kalender.prototype.writemonth = function() {   var = this; 

contains code further down:

  else if ( this.istoday(displaynum, length) && this.islink(displaynum, length) )       {       sbuffer.push('<td class="date" onclick="that.changedate(this,\''                       + this.id + '\'); that.returndate('+ this.month +','+ this.year+')">' + displaynum + '</td>');     }  

this cause problem, since that variable declared within scope of function , onclick event fire outside of scope. imo, building html isn't best method here. best build table cells using dom , add event handlers inside scope of function. happens few times.

fyi, you're using eval() rather unnecessarily in code:

this.months = eval("config.language."+ this.options['language'] +".months");  // can written as: this.months = config.language[this.options['language']].months; 

see eval evil more information.

further reading

msdn - building tables dynamically
mdc - traversing html table javascript , dom interfaces
mdc - working closures


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -