JQuery UI Styles Dissapearing

JQuery UI Styles Dissapearing

izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
edited November 2009 in General
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

Replies

  • ymagasheymagashe Posts: 20Questions: 0Answers: 0
    Hi Izzy,

    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
  • izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
    Hi ymagashe,
    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
  • TomCTomC Posts: 43Questions: 0Answers: 0
    Will instead of stop that validation error? It seems like an easier strategy.
  • izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
    Hi TomC,

    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
  • TomCTomC Posts: 43Questions: 0Answers: 0
    Are you doing something to keep Datatables form displaying the "No matching records found" row? When i get no results I still have one row in the tbody that says that.
  • ymagasheymagashe Posts: 20Questions: 0Answers: 0
    Hi 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
  • izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
    No I am not suppressing the default 'No records' row. What I get is just that when the page initializes it just doesnt seem to validate properly in the firefox html validator my boss is using.

    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
  • ymagasheymagashe Posts: 20Questions: 0Answers: 0
    edited November 2009
    Hi 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]
  • izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
    Summary is on the table header, and the span tags are of the format which are generated by dataTables.
    So not sure what you mean by that.
  • ymagasheymagashe Posts: 20Questions: 0Answers: 0
    Check link below. You will find that start and end tags are required for span.
    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
  • izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
    What I am trying to say is that the span is not of MY creationg, it is added in by dataTables. So is there something maybe in that which is not doing what it is supposed to?
  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin
    Hi guys,

    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
  • ymagasheymagashe Posts: 20Questions: 0Answers: 0
    Hi 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
This discussion has been closed.