The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. January 07, 2009, 08:20:01 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: ajax and css confusion?  (Read 477 times)
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« on: August 03, 2008, 10:13:45 AM »

I have run into an issue, and I am not sure if its me, or code.

if I build a table, with an arbitrary number of rows.
Then, via an ajax call, add a new row to the table, without anything in each TD.
It seems that the new row DOES NOT inherit the styles that were set in a stylesheet when the page first loads.

with ajax, do you need to do inline styles? In otherwords, are new elements that you add to the dom, ignorant of the original stylesheet???
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5324


:sniffle: Humor was so much easier before.


View Profile
« Reply #1 on: August 03, 2008, 11:53:53 AM »

Adding rows to a table dynamically is fraught with peril. Your issue here is one of the doesnt-work-consistently-anywhere items.

That is my experience, that dynamically adding new rows the CSS does not inherit correctly, if at all. But by calling out the class name that you want a row to be then you'll get what you want ie., <tr class="myclass">. It's slightly more pain but quite worth it.
Logged

If I can't be Mr. Root then I don't want to play.
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3525


View Profile
« Reply #2 on: August 03, 2008, 08:16:18 PM »

actually I have discovered this.

weirdness with adding via the dom.
fine when adding via inner html.

so
document.getElementById('tableid').innerHTML = newrow+document.getElementById('tableid').innerHTML;

dumb, but meh, whatever.
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!