declan.lynch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-26 17:06 UTC
How Do I Replace A Tag''s ID ?
I''m currently writing an AJAX based calendar that will appear in the sidebar of a blog. Currently the blog outputs the following Div tag where the ID is the Year-Month. <div id="2007-2" class="CalendarContents"></div> My AJAX routines then finds the element with the CalendarContents class and calls the scripts on the server that generates the calendar table and then populates the innerHTML with the calendar. What I would like to do is add a ''Prev'' and ''Next'' arrow to the calendar so that the user can click on it and get a different calendar generated by the system. I''m trying to approach this by changing the ID for the div and then calling the getCalendar function again but I''m running into difficulties. Does anybody have any suggestions ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey there, declan.lynch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :> I''m trying to approach this by changing the ID for the div and then > calling the getCalendar function again but I''m running into > difficulties.It''s going to be hard to be *less* specific than that. OK first, technically, ''2007-2'' is not a valid ID, although your browser likely accepts it. IDs should start with a letter or underscore, according to spec. Aside from that, $(''yourId'') will get you the element, and you can change its id property. For instance, say you have an item ''cal2007_2'' and want to change it to ''cal2007_3'': $(''cal2007_2'').id = ''cal2007_3''; That should cut it. BTW, are you sure you need to have the current month in the ID? Can''t you store it somewhere else, and keep your calendar element''s ID stable? -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---