using datatables with jquery ui dialog
using datatables with jquery ui dialog
hi
how to use datatable with ui dialog ?
i have 3 links on page, each one opens ui dialog and in this dialog i would like to have datatable.
after load page, it works ok, but only first time i click on link, after second click it opens ui dialog and datatable isn't loading.
my code of page:
index.php file:
[code] //<![CDATA[
$(document).ready(function(){
// onclick dialog opens
$('table').on('click', '.f_button_insert a', function() {
var $link = $(this);
var $thisid = $(this).attr('id');
var $thisidnr = $thisid.substring(12);
var $d = $thisidnr;
$('#uwagi_1').val($d);
var $dialog = $('')
.load($link.attr('href'), {a: $d}) //load dialog from file in attr href with sending var $d
.dialog({ //some dialog options
autoOpen: false,
title: $link.attr('title'),
width: 1000,
height: 485,
modal: true,
buttons: [
{
text: "Pobierz dane",
class: 'insert_submit',
click: function() {
$(this).dialog("close");
}
},
{
text: "Anuluj",
click: function() { $(this).dialog("close"); }
}
]
});
$dialog.dialog('open');
var a = $.fn.dataTableSettings; //adjusting column in datatable
for ( var i=0, iLen=a.length ; i
how to use datatable with ui dialog ?
i have 3 links on page, each one opens ui dialog and in this dialog i would like to have datatable.
after load page, it works ok, but only first time i click on link, after second click it opens ui dialog and datatable isn't loading.
my code of page:
index.php file:
[code] //<![CDATA[
$(document).ready(function(){
// onclick dialog opens
$('table').on('click', '.f_button_insert a', function() {
var $link = $(this);
var $thisid = $(this).attr('id');
var $thisidnr = $thisid.substring(12);
var $d = $thisidnr;
$('#uwagi_1').val($d);
var $dialog = $('')
.load($link.attr('href'), {a: $d}) //load dialog from file in attr href with sending var $d
.dialog({ //some dialog options
autoOpen: false,
title: $link.attr('title'),
width: 1000,
height: 485,
modal: true,
buttons: [
{
text: "Pobierz dane",
class: 'insert_submit',
click: function() {
$(this).dialog("close");
}
},
{
text: "Anuluj",
click: function() { $(this).dialog("close"); }
}
]
});
$dialog.dialog('open');
var a = $.fn.dataTableSettings; //adjusting column in datatable
for ( var i=0, iLen=a.length ; i
This discussion has been closed.
Replies
[code]
$(document).ready(function() {
//
if (typeof tTable == 'undefined') {
tTable = $('.o_table').dataTable( {
"oLanguage": {...},
"sScrollY": 210,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ajax/f_pobierz_towar.php",
"fnServerData": function( aUrl, aoData, fnCallback ) {
$.ajax( {
"url": aUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
},
"aaSorting": [[ 1, "asc" ]],
"aoColumns": [
{ "bVisible": 0 },
null,
null,
null,
null,
null,
{ "bVisible": 0 },
{ "bVisible": 0 }
],
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
if ( jQuery.inArray(aData[0], gaiSelected) != -1 )
{
$(nRow).addClass('row_selected');
}
return nRow;
}
} );
alert('if done');
}
else
{
tTable.fnClearTable( 0 );
tTable.fnDraw();
alert('else done');
}
//select row and get data from row selected
$('.o_table tbody').on( 'click', 'tr', function () {
if ( $(this).hasClass('row_selected') ) {
$(this).removeClass('row_selected');
}
else {
tTable.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
var anSelected = fnGetSelected( tTable );
var aData = tTable.fnGetData( anSelected[0] );
idt = aData[0];
} );
//inserting some data to index.php page
$('.insert_submit').click(function () {
$('#uwagi_3').val(idt);
} );
} );
function fnGetSelected( tTableLocal )
{
return tTableLocal.$('tr.row_selected');
}
Id
Nazwa
Opis
Id
Nazwa
Opis
[/code]
now i have something like this:
1. i click on 'wybierz' link
2. it opens dialog with datatable from insert.php, it is alert 'if done'
3. back to the index.php
4. another click on 'wybierz' link
5. opens dialog, but datatable isnt't load, it is alert 'else done'
how to make datatable to load on second time (and next) ?
1. after load i click first time on the first link 'wybierz' and it works
2. second click on the first link 'wybierz' and it doesn't.
is there any posibility to make that working ?
thanks in advance.