How to pop calendar when text field is clicked?

30 views
Skip to first unread message

drewB

unread,
Oct 6, 2009, 5:31:51 PM10/6/09
to calendar_date_select
I am using the rails gem and want to have the calendar pop up when the
user clicks the text field. I know that using the :popup => 'force'
with make the text field read only but it doesn't pop the calendar
unless you click the image. Is there an option to do that or do I
need to just manually add some javascript that adds an observer on the
text field?

Tim Harper

unread,
Oct 6, 2009, 7:04:31 PM10/6/09
to calendar_d...@googlegroups.com
You're not the first one to request this. With out any changes to the plugin, you'll have to craft the javascript to open the picker yourself.

This would be a great opportunity for refactoring.

Tim

drewB

unread,
Oct 6, 2009, 10:23:08 PM10/6/09
to calendar_date_select
Thanks. Could you point me in the right direction to where I would
modify the plugin to include the extra javascript? If that would take
some work on your part, just let me know. I figured I would ask
before diving into the code searching myself.

On Oct 6, 4:04 pm, Tim Harper <timchar...@gmail.com> wrote:
> You're not the first one to request this. With out any changes to the
> plugin, you'll have to craft the javascript to open the picker yourself.
> This would be a great opportunity for refactoring.
>
> Tim
>

Tim Harper

unread,
Oct 6, 2009, 10:54:00 PM10/6/09
to calendar_d...@googlegroups.com
Just take a look at the onclick attribute of a generated calendar date select control.  It's pretty straightforward.  Just take that javascript code and put in on the text field.  Oh, and the change the $(this).previous() to just $(this)... like so:

FROM THIS: new CalendarDateSelect( $(this).previous(), {year_range:10} );

TO THIS: new CalendarDateSelect( this, {year_range:10} );

Good luck!

Tim

drewB

unread,
Oct 7, 2009, 10:05:39 AM10/7/09
to calendar_date_select
Tim,

Is there an easy way to install CDS as a plugin? I would much rather
modify the code as a plugin so I don't have to worry about
distributing the changes to other machines.

On Oct 6, 7:54 pm, Tim Harper <timchar...@gmail.com> wrote:
> Just take a look at the onclick attribute of a generated calendar date
> select control.  It's pretty straightforward.  Just take that javascript
> code and put in on the text field.  Oh, and the change the
> $(this).previous() to just $(this)... like so:
> FROM THIS: new CalendarDateSelect( $(this).previous(), {year_range:10} );
>
> TO THIS: new CalendarDateSelect( this, {year_range:10} );
>
> Good luck!
>
> Tim
>

Tim Harper

unread,
Oct 7, 2009, 10:14:52 AM10/7/09
to calendar_d...@googlegroups.com

Sure is!

If using git, add it as a submodule into vendor/plugins.  Or just clone it in there and delete the .git directory.

On Oct 7, 2009 8:05 AM, "drewB" <dbat...@gmail.com> wrote:


Tim,

Is there an easy way to install CDS as a plugin?  I would much rather
modify the code as a plugin so I don't have to worry about
distributing the changes to other machines.

On Oct 6, 7:54 pm, Tim Harper <timchar...@gmail.com> wrote: > Just take a look at the onclick attri...

> On Tue, Oct 6, 2009 at 8:23 PM, drewB <dbats...@gmail.com> wrote: > > > Thanks.  Could you point m...

drewB

unread,
Oct 7, 2009, 2:36:14 PM10/7/09
to calendar_date_select
Thanks for the help. I added a :auto_pop option. If you would like
to incorporate this changes into a future release let me know and I am
happy to send them along in whatever format is easiest for you.

On Oct 7, 7:14 am, Tim Harper <timchar...@gmail.com> wrote:
> Sure is!
>
> If using git, add it as a submodule into vendor/plugins.  Or just clone it
> in there and delete the .git directory.
>
Reply all
Reply to author
Forward
0 new messages