fnOpen adds to two locations

fnOpen adds to two locations

dlouwersdlouwers Posts: 2Questions: 0Answers: 0
edited December 2009 in Bug reports
Hi,

I am fairly new to the plugin but have noticed the following:

I have a few hidden divs, each belonging to a row. When a row is selected the fnOpen is called on it supplying $(theHiddenDiv).html() as the content to display. This works like a charm BUT the html is also added somewhere near the end of my page. This is NOT the original hidden div moved or anything but actually the html that I supplied to fnOpen. The html remains there when fnClose is called on the table.

Hope someone can help me solve this show-stopper.

Best,

Dirk

Replies

  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin
    Hi Dirk,

    Sounds like an interesting problem (the best kind... :-) ). So when you insert the html copied from the hidden div, it inserts it into two different locations? That would suggest that the selector you are using for the insert is picking up two different elements - this could be confirmed with alert( $({selector}).length );

    Also how are you using fnOpen? fnOpen will add a new TR element to the table with a child TD which you can then insert the content into. Any chance you can post a link to an example showing this?

    Regards,
    Allan
  • dlouwersdlouwers Posts: 2Questions: 0Answers: 0
    Hi Allan,

    Even when the selector picks up 2 different elements the html() method should only output content for the first element as stated by the jQuery docs. Also it getting outputted to two different locations would be odd in that case.

    I am adding two divs, so nothing illegal, like table tags.

    The "second" unwanted output is added to a new table row and that corresponds to the rows in my datatable. This tr is added to the outermost table on the page. So it seems like something is going wrong with the selection of the table/row the new row needs to be added after.

    Hope this helps you pinpoint it.

    Best,

    Dirk
  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin
    Hi Dirk,

    Ah I see - sorry, I thought you were using $().html() to set the HTML, which does set all matching elements, rather than to get the original from your hidden element, which are you completely right about setting only the first element.

    I'm still not quite clear on what the issue is though - sorry... Is there any chance you can show an example with this issue? Presumably the new table row that the output is being added to is the one created by fnOpen? I'm not quite clear on how it's being used.

    Thanks,
    Allan
This discussion has been closed.