How might you unobtrusively enhance the jQuery Datepicker class?
Posted
by Teflon Ted
on Stack Overflow
See other posts from Stack Overflow
or by Teflon Ted
Published on 2010-03-15T14:53:38Z
Indexed on
2010/03/15
15:49 UTC
Read the original article
Hit count: 196
You can pass special strings into jQuery's Datepicker class setDate() method like "+7" which will be translated into "7 days from today":
http://docs.jquery.com/UI/Datepicker#method-setDate
But you can't get that "+7" back out. When you call getDate() you get the calculated resulting date.
I have a use case where I need to pull out the special string "+7" for propagation. One chunk of code is passing a special string into the Datepicker and passing the Datepicker over to another chunk of code which pulls out the date, but the latter sometimes needs to know the special string rather than the calculated date.
So I need to enhance the Datepicker tool to (a) store the special code internally and (b) expose it via a method like getOriginallyPassedInDate() or some such.
I'm not a jQuery/Javascript ninja so I could really use some guidance on how I might preferably-unobtrusively add the necessary functionality to the Datepicker class, the way you might monkey-patch an object in Ruby I'm guessing.
© Stack Overflow or respective owner