Server-side hidden rows example, having problems attaching event to the image

Server-side hidden rows example, having problems attaching event to the image

bicklebickle Posts: 8Questions: 0Answers: 0
edited April 2014 in DataTables 1.10
I'm following along with the server-side hidden rows example (http://82.113.152.82/release-datatables/examples/server_side/row_details.html), and I can't seem to get the events to attach to the image so that the grid can expand or contract.

I mocked up a sample here: http://live.datatables.net/gopatiz/2/edit?html,css,js,output , although since the example required an additional field in the the json results, I linked it to a separate datasource and that doesn't load (locally it loads fine). But at least with the source listed, you can see what the json output looks like. Also, just to see if the even was firing at all, I threw in an alert, and that isn't appearing when I click on the image.

I tried a few different things, and found that I can listen for an event on the tbody click, but not on tr/td/img. I'm not sure what that means, but thought it might be helpful.

Any suggestions on what I need to look at in order to fix this? Thanks,

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > $('#example tbody td img').on('click', function () {

    You are using a static event and applying it to the document before any data has loaded (Therefore there is nothing to attach the event to). You want to use a jQuery delegated event. See the top FAQ: http://datatables.net/faqs#events .

    See also the updated 1.10 example: http://next.datatables.net/examples/server_side/row_details.html

    Allan
  • bicklebickle Posts: 8Questions: 0Answers: 0
    Got it, thanks!
This discussion has been closed.