WJRANKIN-J6ISH/MDR2c@public.gmane.org
2006-May-04 15:29 UTC
How to insert styles with Insertion
Hi, I''m having difficulty using Prototype''s Insertion method to insert styles into a document node. Code like this seems to fail: new Insertion.Top(widgets[i], ''<style type="text/css"></style>''); When I inspect the DOM, the style is nowhere to be found. Any ideas on how to get this to work? Thank you, Jeff Rankin Human Factors 544-4333
The Insertion object (Abstract) This object serves as the root for other classes in the library. It does not have any properties or methods. The classes defined in this object are also treated as traditional abstract classes. Now, I might be wrong, but I am pretty sure whatever you are trying to do, isn''t supposed to be done the way you are trying to. Are you just trying to dynamically include an external CSS file or are you just trying to apply a style to a node? -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of WJRANKIN-J6ISH/MDR2c@public.gmane.org Sent: Thursday, May 04, 2006 11:30 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] How to insert styles with Insertion Hi, I''m having difficulty using Prototype''s Insertion method to insert styles into a document node. Code like this seems to fail: new Insertion.Top(widgets[i], ''<style type="text/css"></style>''); When I inspect the DOM, the style is nowhere to be found. Any ideas on how to get this to work? Thank you, Jeff Rankin Human Factors 544-4333 _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I know this works: document.write(''<link rel="STYLESHEET" type="text/css" href="''+sheetUrl+''"></link>''); While done between the <head> and </head> tag. -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Martinez, Andrew Sent: Thursday, May 04, 2006 11:36 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] How to insert styles with Insertion The Insertion object (Abstract) This object serves as the root for other classes in the library. It does not have any properties or methods. The classes defined in this object are also treated as traditional abstract classes. Now, I might be wrong, but I am pretty sure whatever you are trying to do, isn''t supposed to be done the way you are trying to. Are you just trying to dynamically include an external CSS file or are you just trying to apply a style to a node? -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of WJRANKIN-J6ISH/MDR2c@public.gmane.org Sent: Thursday, May 04, 2006 11:30 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] How to insert styles with Insertion Hi, I''m having difficulty using Prototype''s Insertion method to insert styles into a document node. Code like this seems to fail: new Insertion.Top(widgets[i], ''<style type="text/css"></style>''); When I inspect the DOM, the style is nowhere to be found. Any ideas on how to get this to work? Thank you, Jeff Rankin Human Factors 544-4333 _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
WJRANKIN-J6ISH/MDR2c@public.gmane.org
2006-May-04 15:43 UTC
RE: How to insert styles with Insertion
I''m trying to apply styles to a node. The style selectors contain dynamic information (IDs) that limit the style''s effects to a specific node. I''m using Insertion.Top to insert the styles. It''s interesting, when I wrap the styles in a para element as shown below, the para element is inserted, but not the contained styles: new Insertion.Top(widgets[i], ''<p><style type="text/css">...</style></p>''); Is there another method I should be using? Thanks, Jeff Rankin Human Factors 544-4333 "Martinez, Andrew" <Andrew.Martinez-vMz6ma+x7bnQT0dZR+AlfA@public.gmane.org> To: <rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent by: cc: (bcc: William J. Rankin/UPC) rails-spinoffs-bounces-1W37MKcQCpIbvKGg9ot7NQ@public.gmane.org Subject: RE: [Rails-spinoffs] How to insert styles with Insertion onrails.org 05/04/2006 10:35 AM Please respond to rails-spinoffs The Insertion object (Abstract) This object serves as the root for other classes in the library. It does not have any properties or methods. The classes defined in this object are also treated as traditional abstract classes. Now, I might be wrong, but I am pretty sure whatever you are trying to do, isn''t supposed to be done the way you are trying to. Are you just trying to dynamically include an external CSS file or are you just trying to apply a style to a node? -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of WJRANKIN-J6ISH/MDR2c@public.gmane.org Sent: Thursday, May 04, 2006 11:30 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] How to insert styles with Insertion Hi, I''m having difficulty using Prototype''s Insertion method to insert styles into a document node. Code like this seems to fail: new Insertion.Top(widgets[i], ''<style type="text/css"></style>''); When I inspect the DOM, the style is nowhere to be found. Any ideas on how to get this to work? Thank you, Jeff Rankin Human Factors 544-4333 _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I''ve run into this problem before, and maybe someone has an answer to this. But outside of the <head> </head> tags I''ve never had a browser reliably add the styles node. If you wish to just apply a style to a node then you can just create a class that has the styles you want and then you can do someNode.className = "myClassName"; -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of WJRANKIN-J6ISH/MDR2c@public.gmane.org Sent: Thursday, May 04, 2006 11:44 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] How to insert styles with Insertion I''m trying to apply styles to a node. The style selectors contain dynamic information (IDs) that limit the style''s effects to a specific node. I''m using Insertion.Top to insert the styles. It''s interesting, when I wrap the styles in a para element as shown below, the para element is inserted, but not the contained styles: new Insertion.Top(widgets[i], ''<p><style type="text/css">...</style></p>''); Is there another method I should be using? Thanks, Jeff Rankin Human Factors 544-4333 "Martinez, Andrew" <Andrew.Martinez-vMz6ma+x7bnQT0dZR+AlfA@public.gmane.org> To: <rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent by: cc: (bcc: William J. Rankin/UPC) rails-spinoffs-bounces-1W37MKcQCpIbvKGg9ot7NQ@public.gmane.org Subject: RE: [Rails-spinoffs] How to insert styles with Insertion onrails.org 05/04/2006 10:35 AM Please respond to rails-spinoffs The Insertion object (Abstract) This object serves as the root for other classes in the library. It does not have any properties or methods. The classes defined in this object are also treated as traditional abstract classes. Now, I might be wrong, but I am pretty sure whatever you are trying to do, isn''t supposed to be done the way you are trying to. Are you just trying to dynamically include an external CSS file or are you just trying to apply a style to a node? -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of WJRANKIN-J6ISH/MDR2c@public.gmane.org Sent: Thursday, May 04, 2006 11:30 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] How to insert styles with Insertion Hi, I''m having difficulty using Prototype''s Insertion method to insert styles into a document node. Code like this seems to fail: new Insertion.Top(widgets[i], ''<style type="text/css"></style>''); When I inspect the DOM, the style is nowhere to be found. Any ideas on how to get this to work? Thank you, Jeff Rankin Human Factors 544-4333 _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hi Jeff, WJRANKIN-J6ISH/MDR2c@public.gmane.org wrote:> Hi, > > I''m having difficulty using Prototype''s Insertion method to insert > styles into a document node. Code like this seems to fail: > > new Insertion.Top(widgets[i], ''<style type="text/css"></style>''); > > When I inspect the DOM, the style is nowhere to be found. > > Any ideas on how to get this to work? Thank you,Although most browsers will accept CSS declarations inside <script></script> tags just about anywhere in a static HTML-soup document, they are only legal within the <head> of the document, not in the <body>, so the DOM rejects adding them dynamically there. -dave