|
Posted by lcplben on November 22, 2009, 1:28 pm
Please log in for more thread options
Hi folks --
I don't have much hope for a Eureka! answer, but here goes anyway.
I apologize that I can't post a URL: the page is in pieces all over
the garage floor. But imagine I have a page arranged in an ordinary
way:
show/hide quoted text
<html><head>
<script ...> Javascript functions </script>
<style ...> styles </style>
</head>
<body>
<div></div>...<div></div>
show/hide quoted text
<div id="container"> // div.parentNode == <body>
show/hide quoted text
<table id="data">
[bunch of complicated data]
show/hide quoted text
</table>
show/hide quoted text
</div> // id="container"
show/hide quoted text
</body></html>
I replace (via AJAX) the div id="container", and its contained table
id="data", with new stuff when the user asks me to, and that will work
just fine, I do believe. It's somewhat working now.
show/hide quoted text
The "old" table depends heavily (maybe too much) upon the <style>
section in the <head>. But when the table of new, refreshed data shows
up, of course it's completely unstyled. I haven't found a way to get
the browser to apply styles from that section or from an external
stylesheet to the new table.
Has anybody any ideas about how I can get the new, AJAX-downloaded
show/hide quoted text
stuff to acquire some style? Short of styling every single <th> and
<td>, thereby pumping up the style part of the data/style ratio from
merely humongous to gigantic.
I do see ( http://www.w3.org/TR/html4/present/styles.html#h-14.2.1 )
that I can put out an HTTP header:
Content-Style-Type: text/css
but I don't think that helps the browser find the styles I want.
Thank you, everyone.
-- ben
|
|
Posted by Dan Rumney on November 23, 2009, 9:06 am
Please log in for more thread options
show/hide quoted text
> Has anybody any ideas about how I can get the new, AJAX-downloaded
> stuff to acquire some style? Short of styling every single <th> and
> <td>, thereby pumping up the style part of the data/style ratio from
> merely humongous to gigantic.
>
Any styling defined for a page will be applied to any elements added to
the DOM.
What seems likely to me is one of two scenarios:
1) The method that you use to add elements to you DOM wipes out the <div
show/hide quoted text
id="container"> element, rendering your styling ineffective
2) Your styling is too specific to the original elements; the new
elements are not matched by any of the selectors in your CSS so no
styling is applied.
This is a case where we need a URL to really figure out what is happening
Dan
|
|
Posted by lcplben on November 24, 2009, 6:24 am
Please log in for more thread options
show/hide quoted text
> > Has anybody any ideas about how I can get the new, AJAX-downloaded
> > stuff to acquire some style? Short of styling every single <th> and
> > <td>, thereby pumping up the style part of the data/style ratio from
> > merely humongous to gigantic.
> Any styling defined for a page will be applied to any elements added to
> the DOM.
Am I inferring correctly from this that an AJAX-downloaded element (a
show/hide quoted text
<div>, say) causes the page to be re-rendered? That would make sense
and would solve my problem.
show/hide quoted text
> 1) The method that you use to add elements to you DOM wipes out the <div
> id=3D"container"> element, rendering your styling ineffective
show/hide quoted text
Yes, it intends to wipe out/replace the "old" <div id=3D"container">
with a new div that is /supposed/ to be identical (in id and
everything else) to the old, except only that the new element has new
content.
show/hide quoted text
> 2) Your styling is too specific to the original elements; the new
> elements are not matched by any of the selectors in your CSS so no
> styling is applied.
I didn't think of that. Thanks.
show/hide quoted text
> This is a case where we need a URL to really figure out what is happening
Yes, indeedy. I'll give one next time.
Thanks so much, Dan.
-- ben
|
|
Posted by lcplben on November 24, 2009, 6:57 am
Please log in for more thread options
show/hide quoted text
> Am I inferring correctly from this that an AJAX-downloaded element (a
> <div>, say) causes the page to be re-rendered? That would make sense
> and would solve my problem.
D'oh! OF COURSE the page is re-rendered -- I wasn't thinking straight.
Never mind (tm Emily Litella).
-- ben
|
|
Posted by Harlan Messinger on November 24, 2009, 8:59 am
Please log in for more thread options
lcplben wrote:
show/hide quoted text
>>> Has anybody any ideas about how I can get the new, AJAX-downloaded
>>> stuff to acquire some style? Short of styling every single <th> and
>>> <td>, thereby pumping up the style part of the data/style ratio from
>>> merely humongous to gigantic.
>> Any styling defined for a page will be applied to any elements added to
>> the DOM.
>
> Am I inferring correctly from this that an AJAX-downloaded element (a
> <div>, say) causes the page to be re-rendered? That would make sense
> and would solve my problem.
That is incorrect. But the browser has to render the elements that you
*insert*, and when it does so, it applies the applicable stylesheets to
them the same way it did to the original state of the page.
|
| Similar Threads | Posted | | how to style an AJAX-loaded fragment | November 22, 2009, 1:10 pm |
| Empty fragment | July 7, 2005, 10:10 am |
| Centered fragment in a paragraph | June 3, 2008, 3:53 pm |
| Weird: IE renders fragment of HTML twice | January 31, 2006, 5:09 am |
| XHTML DOCTYPE breaks JavaScript x.style.top and x.style.left? | July 5, 2005, 12:58 pm |
| TR's w no Style? | October 5, 2005, 4:27 pm |
| style=& ? | November 22, 2004, 7:24 am |
| using vars in div style tag | January 5, 2005, 4:32 pm |
| Footnote style | September 25, 2005, 8:38 pm |
| OL tag with style for decrementing? | February 28, 2007, 1:09 am |
|
<script ...> Javascript functions </script>
<style ...> styles </style>
</head>
<body>
<div></div>...<div></div>