Actually I have 2 questions. The first: is this mailing list about Ruby on Rails or Prototype? The list address according to Google Groups is named "Ruby on Rails: Spinoffs"... My real question: I''m generating a few nested DIV elements, setting styles on these, and then attaching to the document. The style rules are defined in a STYLE section of the head, and work as expected in Firefox. However in IE, some of the styles do not show up until I drag the newly created DIV (which is Draggable). Any thoughts? Here''s a snippet: var playlistItem = $(document.createElement(''div'')); playlistItem.id = params.mediaID; playlistItem.addClassName(''playlistItem''); var dragger = $(document.createElement(''div'')); dragger.addClassName(''playlistDragger''); var title = $(document.createElement(''div'')); title.addClassName(''playlistItemTitle''); title.update(params.mediaTitle); title.onclick = function() { PopupPlayer.playItem(params); } var metaData = $(document.createElement(''div'')); metaData.addClassName(''playlistItemMetaData''); metaData.update("Artist, YYY, ..."); var deleteButton = $(document.createElement(''div'')); deleteButton.addClassName(''deleteButton''); deleteButton.update(''x''); deleteButton.onclick = function() { PopupPlayer.removeItem(playlistItem.id); } playlistItem.appendChild(dragger); playlistItem.appendChild(deleteButton); playlistItem.appendChild(title); playlistItem.appendChild(metaData); $(''playlist'').appendChild(playlistItem); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ah, new evidence: the elements are correctly styled, but it''s when I then do a Sortable.create() on the containing DIV that for some reason the styles stop being rendered, only to reappear when I drag the newly added DIV. What''s weirder, since I make this call each time, effectively destroying the existing Sortable and re-creating with one more element in the list, is that it''s only the newly added element that gets rendered funny (and only in IE(7)). I also tried doing setTimeout(function() { Sortable.create(...); }, 1000); All this does is confirm its the Sortable call that is doing something odd. The element shows up correctly styled, and one second later, the styling disappears. This includes background-color, border, and some layout, though the text is all correctly styled. I should add, this is Scriptaculous 1.8.0 with Prototype 1.6.0. I''ll go check the Scriptaculous support areas too. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try creating your element this way, which is a new feature of Prototype 1.6. $(document.body).insert(new Element("div", { id: params.mediaID, class:''playlistItem'', onclick:''alert("moo")'' })) I''m not sure it will make any difference but it''s worth a try. On Dec 21, 10:07 am, Jason Boyd <jayb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ah, new evidence: the elements are correctly styled, but it''s when I > then do a Sortable.create() on the containing DIV that for some reason > the styles stop being rendered, only to reappear when I drag the newly > added DIV. What''s weirder, since I make this call each time, > effectively destroying the existing Sortable and re-creating with one > more element in the list, is that it''s only the newly added element > that gets rendered funny (and only in IE(7)). > > I also tried doing > > setTimeout(function() { Sortable.create(...); }, 1000); > > All this does is confirm its the Sortable call that is doing something > odd. The element shows up correctly styled, and one second later, the > styling disappears. This includes background-color, border, and some > layout, though the text is all correctly styled. > > I should add, this is Scriptaculous 1.8.0 with Prototype 1.6.0. I''ll > go check the Scriptaculous support areas too.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nicolás Sanguinetti
2007-Dec-21 21:18 UTC
Re: inserted elements not styled until interaction
On Dec 21, 2007 6:22 PM, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Try creating your element this way, which is a new feature of > Prototype 1.6. > > $(document.body).insert(new Element("div", { id: params.mediaID, > class:''playlistItem'', onclick:''alert("moo")'' }))Don''t add inline event handlers when creating elements or using writeAttribute. And ''class'' is a reserved keyword, you must either use className or quote it. new Element("div", { id: params.mediaID, className: ''playlistItem'' }).observe("click", function() { alert("moo") }) Best, -Nicolas> > I''m not sure it will make any difference but it''s worth a try. > > > On Dec 21, 10:07 am, Jason Boyd <jayb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Ah, new evidence: the elements are correctly styled, but it''s when I > > then do a Sortable.create() on the containing DIV that for some reason > > the styles stop being rendered, only to reappear when I drag the newly > > added DIV. What''s weirder, since I make this call each time, > > effectively destroying the existing Sortable and re-creating with one > > more element in the list, is that it''s only the newly added element > > that gets rendered funny (and only in IE(7)). > > > > I also tried doing > > > > setTimeout(function() { Sortable.create(...); }, 1000); > > > > All this does is confirm its the Sortable call that is doing something > > odd. The element shows up correctly styled, and one second later, the > > styling disappears. This includes background-color, border, and some > > layout, though the text is all correctly styled. > > > > I should add, this is Scriptaculous 1.8.0 with Prototype 1.6.0. I''ll > > go check the Scriptaculous support areas too. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for these tips. I just upgraded to the newer libs but had forgotten this gives me some cool new stuff. Not sure it''ll solve my problem, but useful nonetheless. -Jason --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---