Initiating a jQuery UI dialog box on click

Initiating a jQuery UI dialog box on click

EotSEotS Posts: 9Questions: 1Answers: 0
edited August 2014 in DataTables 1.10

I can get an alert to pop using this code:

 $(document).ready(function() {
         $('#test').dataTable({
                "sPaginationType":"full_numbers",
                "sAjaxSource": "tables/test.php",
                "sAjaxDataProp": "",                    
                "aaSorting":[[7, "desc"]],
                "bJQueryUI":true,

            });

       $('#test tbody').on('click', 'tr', function () {
          var name = $('td', this).eq(0).text();
          alert( 'You clicked on '+name+'\'s row' );

} );

         });

But when I try to pop a jQuery UI dialog box in the function, like so:

    $('#test tbody').on('click', 'tr', function () {
    $( "#dialog" ).dialog( "open" );
          } );

I get: "Error: cannot call methods on dialog prior to initialization; attempted to call method 'open'"

Can someone give me an idea why this is happening, and how to make it work?

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Sounds like you haven't initialised the jQuery UI dialog box.

    I would suggest disabling DataTables in the first instance, and seeing if you can get the dialog box to work without DataTables. Then try adding it with DataTables. I don't think DataTables itself has anything to do with the error above (although I might be wrong!).

    Allan

This discussion has been closed.