JQuery UI Styles Dissapearing
JQuery UI Styles Dissapearing
Hi,
I have just run into a strange problem. Well not so much a problem as it is an annoyance. I have some pages that just load data into tables then lets dataTables do all the sorting and stuff. However if there is no data to return it leaves the tbody empty (this is not sematicaly good, and my boss is vigilant on his firefox validator which shows an error on the page). However If i put a single row in with the dataTables empty class (which is what dataTables does when no data is found with the relevant filtering) the dataTables does not seem to do anything and all my JQuery UI styling dissapears.
Is there a way on initialisation for dataTables to check for existance of this single "empty" row and remove it then process the table as normal? or am I missing something.
I cant give a URL for this as it is on our secure server, but if needed I will try to put an example page together tonight to demonstrate this issue.
Regards,
Izzy
I have just run into a strange problem. Well not so much a problem as it is an annoyance. I have some pages that just load data into tables then lets dataTables do all the sorting and stuff. However if there is no data to return it leaves the tbody empty (this is not sematicaly good, and my boss is vigilant on his firefox validator which shows an error on the page). However If i put a single row in with the dataTables empty class (which is what dataTables does when no data is found with the relevant filtering) the dataTables does not seem to do anything and all my JQuery UI styling dissapears.
Is there a way on initialisation for dataTables to check for existance of this single "empty" row and remove it then process the table as normal? or am I missing something.
I cant give a URL for this as it is on our secure server, but if needed I will try to put an example page together tonight to demonstrate this issue.
Regards,
Izzy
This discussion has been closed.
Replies
I do have a page where datatables returns no matching records found. My DTD is XHTML 1.0 Transitional. It validates without any errors. Whats your DTD?
Have you closed tbody tag?
Regards,
Yogesh
My DTD is also XHTML 1.0 Transitional.
It is not really an error, it is just that my boss likes to see green on his HTML Validator which is currently showing an error of:
[code]
line 568 column 23 - Error: end tag for "tbody" which is not finished
[/code]
I am guessing that this is because there is physically no data in the table's markup before dataTables initialises. So am looking for a way to 'fool' the validator by adding a single row which dataTables will then remove and process normally.
Regards,
Izzy
Nope still no luck this time i get 2 errors, this time relating to both parts of the tag (begining stating there is no the tbody is not finished, and the closing end part of the tag also stating the tbody is not finished)
Regards,
Izzy
It's surprising, because I am not getting this error and in face we are having same doctype.
Can you post the generated code for the table?
Regards,
Yogesh
This is what the validator is seeing
[code]
Date
From
Subject
Church
[/code]
And this is what the page is actually showing
[code]
Date
From
Subject
Church
No matching records found
[/code]
as you can see the validator is not picking up on the dataTables DOM added no records row.
My sugestion is a simple one for me to be able to add a single default row to my table markup that dataTables then removes as a junk row. that way the validator will validate and my boss will be a happy bunny.
Really appreciate all the suggestions so far.
Regards,
Izzy
You have not closed the span tag and inside th elements. Also add summary to the table markup.
Hope this helps.
Yogesh
[code]
Date
From
Subject
Church
No matching records found
[/code]
So not sure what you mean by that.
http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-SPAN
Just try to copy paste your table code in a plain xhtml page and you will find that you get an error for span tag. That's why I said you have not closed span tag. If they are generated automatically, then I am afraid I don't have an answer.
Hopefully someone else will come in and help you out.
Best,
Yogesh
One thing to remember is that validation will almost always occur on non-Javascript enhanced source (i.e. just the raw HTML with JS switched off). As such, I don't think the problem will be caused by the tag.
The HTML specification says:
"When present, each THEAD, TFOOT, and TBODY contains a row group. Each row group must contain at least one row, defined by the TR element."
http://www.w3.org/TR/html401/struct/tables.html#h-11.2.3
Therefore, the validation is failing for exactly the reason that the validator says - the tbody element isn't finished, because it's missing content. The way to 'fix' this is to simply add a place holder TR with something like "Loading data from server, please wait". With server-side processing, DataTables will nuke this row when the draw occurs, validation will be okay, and everyone is happy :-) (hopefully!).
Regarding the span issue... It's added into the DOM by document.createElement('span') - which is why it doesn't have a specific opening and closing tag, so this should be acceptable - at least to the browser itself...!
Regards,
Allan
Thanks for the clarification. As naive as it may sound, I didn't know that validation almost always occurs on non-Javascript enhanced source.
Regards,
Yogesh