Javascript, Helpers and DRY


I’m using the calendar_helper plugin to generate javascript for popup calendars. It works nicely.

Now, I’d like to create a Ajax.InPlaceDateEditor in the javascript libs, so that when a user clicks a date field they’ll be given an in place editor that can be set with a popup calendar. I’ve done similar things in the past, but only when I wasn’t using helpers to generate controls. I’m struggling with how to keep this DRY…is there any way you can think of to make use of the logic contained within the calendar_helper methods…but from within an inplaceeditor? The only rough guess I have at the moment is making an Ajax call in the background to a controller method that would call the helper and return the outputted javascript, but somehow this feels dirty.

Any suggestions will be very much appreciated. If I rambled too much for you to understand what I’m trying to do, just say so and I’ll back up an repeat myself. I’m going on too much coffee this morning.