Wow, I got it! It turns out that the calendar relies on having a
hidden field in the div where i add the calendar.

Once you explained what exactly
'(\'cds_placeholder_105hd1\').previous()' was doing I just set it back
to $('date_area') which I had tried before, but then I added the
hidden input field and it worked. Obviously I don't fully know how
this calendar component works, and the docs are a but lacking.

But with your help I figured it out. Thanks again!

On Mar 19, 10:14 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
> Hi,
>
> > Well, I'm inserting it into a div node so it knows where to be layed
> > out.
>
> Rushing out the door, but:
>
> Where a script tag is in the page only matters during initial page
> load, and then only 1) in terms of the order in which the scripts in
> the various tags get executed, and/or 2) if the scripts use
> `document.write` to output to the page as it's parsed.
>
> From your code snippet, I didn't take your calendar control to be the
> kind that relies on `document.write` (which is very old-fashioned and
> generally not a good idea). It looks like it interacts with a pre-
> existing element in the page -- specifially, whatever element is just
> before the one with the ID "cds_placeholder_105hd1" in your page,
> because you're looking up that element by ID (the `$
> ('cds_placeholder_105hd1')` part), and then going to the previous
> element (the `.previous()` part).
>
> Do you _already_ have a calendar on that element? Or does that element
> not exist? I think those may be where the problem lies.
>
> Good luck,
> --
> T.J. Crowder
> Independent Software Consultant
> tj / crowder software / comwww.crowdersoftware.com
>
> On Mar 19, 5:02 pm, 99miles <99mi...@gmail.com> wrote:
>
> > Well, I'm inserting it into a div node so it knows where to be layed
> > out. Basically I have:
>
> > document.observe('dom:loaded', function() {
> >         loader();
>
> > });
>
> > So if loader() just consists of what you have, it doesn't know where
> > to be drawn.
> > So, neither of these attempts result in the calendar being drawn on
> > screen.
>
> > Does that make any more sense?
>
> > On Mar 19, 9:54 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
>
> > > Hi,
>
> > > I think I'm misunderstanding, why do you need to use script to create
> > > a script tag with inline script? Wouldn't it work just to do the work
> > > directly? E.g.:
>
> > > function loader() {
>
> > >     new CalendarDateSelect(
> > >         $('cds_placeholder_105hd1').previous(),
> > >         {
> > >             embedded:   true,
> > >             year_range: 10
> > >         }
> > >     );
>
> > > }
>
> > > That should have exactly the same effect as inserting a script tag to
> > > do it...or am I missing something?
>
> > > HTH,
> > > --
> > > T.J. Crowder
> > > Independent Software Consultant
> > > tj / crowder software / comwww.crowdersoftware.com
>
> > > On Mar 19, 3:56 pm, 99miles <99mi...@gmail.com> wrote:
>
> > > > When the dom is loaded, I call this method where I try to insert a
> > > > CalendarDateSelect into an existing div tag, but it's not working:
>
> > > > function loader() {
> > > >         var newScript   = document.createElement('script');
> > > >         newScript.type  = 'text/javascript';
> > > >         newScript.innerHTML = 'new CalendarDateSelect( $
> > > > (\'cds_placeholder_105hd1\').previous(), {embedded:true, year_range:
> > > > 10} );';
> > > >         //newScript.innerHTML = 'alert("foo")';
> > > >         $('date_area').insert(newScript);
>
> > > > }
>
> > > > But, if I comment out the first 'innerHTML' line, and uncomment the
> > > > second, the alert pops up as expected. So, it seems like this should
> > > > work.
>
> > > > CalendarDateSelect is a component 
> > > > fromhttp://code.google.com/p/calendardateselect/wiki/JavascriptDocumentation,
> > > > and that call should create a calendar. I have other pages where I
> > > > display the calendar from ruby on rails code which ends up outputting
> > > > the following and it display just great.
>
> > > > <script type="text/javascript">
> > > >   //<![CDATA[
> > > >   new CalendarDateSelect( $('cds_placeholder_10511').previous(),
> > > > {embedded:true, year_range:10} );
> > > >   //]]>
> > > >   </script>
>
> > > > Any ideas?
> > > > Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to