Open a jQuery.Dialog() in DataTables - not working

Open a jQuery.Dialog() in DataTables - not working

peter.jansenpeter.jansen Posts: 9Questions: 0Answers: 0
edited May 2011 in General
Hi,

we have a DataTable with an image-link in every row (last col has an edit-icon). This link opens a jQuery.Dialog(). This works very well, BUT only at first "page". If we go to the next page by clicking on the paginate link, the link doesn't work (it opens the target page not as a dialog, but the normal way.)

I hope somebody can help us. Thx in advance.

==============
using:
1. jQuery: jquery-1.6.1.min.js
2. DataTables: 1.7.6.

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    http://datatables.net/faqs#events :-)

    Allan
  • peter.jansenpeter.jansen Posts: 9Questions: 0Answers: 0
    I still read this and also tried it ;-)

    I changed this code:
    [code]$("#" + openerId).click(function () { ... });[/code]

    to this one:
    [code]$("#" + openerId).live('click', function () { ... });[/code]

    but now, some links are working, other ones not. but this very random. what can I also do?
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Do you not want the events attached to the rows:

    $("#" + openerId+" tr").live('click', function () { ... });

    Allan
  • peter.jansenpeter.jansen Posts: 9Questions: 0Answers: 0
    edited May 2011
    thx for your reply.

    the "problem" was, that we are using a control (asp.net mvc html-helper control), which setup the whole html and javascript code for a dialog. but on this way it was not possible ...

    now I throw every code away and start a new (normal) way with live(click) instead of click :) and it works - on every table "page"

    The Html-Code is only an a-tag and a div in the last cell of every row
    [code]




    [/code]

    and our javascript code is like this... maybe somebody need it similar ;-)
    [code]
    $('#tblDocument tbody td img').live('click', function (event) {
    event.preventDefault();
    if (this.src.match('edit')) {
    var nTd = this.parentNode.parentNode; // cell element
    var dialogId = "_<%= Guid.NewGuid().ToString("N") %>";
    var openerLink = $(nTd).children('a:first').attr('href');
    $(nTd).children('div:first').attr('id', dialogId);

    global.dialog.init(dialogId,this.alt,openerLink,700,670,'Save');
    global.dialog.open(dialogId, openerLink);
    return false;
    }
    });
    [/code]
This discussion has been closed.