Problem with saveing datatable in local storage
Problem with saveing datatable in local storage
tommy
Posts: 1Questions: 0Answers: 0
hi,
i have problems with saving and loading my datatable in local storage, can sb tell what im doing wrong?
this is my all code
[code]
$(document).ready(function () {
$('#table-2').dataTable({
});
$(document).click(function() {
$('#table-2').dataTable( {
"bStateSave": true,
"fnStateSave": function (oSettings, oData) {
localStorage.setItem( 'DataTables_'+window.location.pathname, JSON.stringify(oData) );
},
"fnStateLoad": function (oSettings) {
var data = localStorage.getItem('DataTables_'+window.location.pathname);
return JSON.parse(data);
}
} );
} );
$(document).ready(function () {
var startPosition;
var endPosition;
$("#table-2 tbody").sortable({
cursor: "move",
start: function (event, ui) {
startPosition = ui.item.prevAll().length + 1;
},
update: function (event, ui) {
endPosition = ui.item.prevAll().length + 1;
}
});
});
$(document).ready(function () {
$('#table-2').dataTable({
"sPaginationType": "full_numbers"
});
});
(function () {
var bsa = document.createElement('script');
bsa.type = 'text/javascript';
bsa.async = true;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(bsa);
})();
$(document).ready(function () {
$('.usun').live('click', function () {
$(this).closest('tr').animate({ 'color': '#fff' }, 300, function () {
$(this).remove();
});
});
});
$('.olowek').live('click', function () {
$(this).closest('td').animate({}, 300, function () {
if ($(this).text() == "tak") {
$(this).html("nie")
} else if ($(this).text() == "nie") {
$(this).html("tak")
}
});
});
$(document).ready(function () {
$('.text').editable('save.php', {
type: 'text',
cancel: 'Anuluj',
submit: 'Zapisz',
indicator: '',
width: '100px'
});
})
$(document).ready(function () {
$('#table-2').dataTable();
var ile = $('#table-2').dataTable().fnSettings().fnRecordsTotal();
});
/* Global var for counter */
var giCount = $('#table-2').dataTable().fnSettings().fnRecordsTotal();
$(document).ready(function () {
$('#table-2').dataTable();
});
function aaa() {
$(".formularz").css('visibility', 'visible').css("position", "relative");
}
function bbb() {
$(".formularz").css('visibility', 'hidden').css("position", "absolute");
}
var a;
function fnClickAddRow() {
var random = Math.round(Math.random() * 10);
a = document.getElementById("otwarta").value + "";
$('.usun').live('click', function () {
$(this).closest('tr').animate({ 'color': '#fff' }, 300, function () {
$(this).remove();
});
});
if (document.getElementById("PL").value.length != 0 && document.getElementById("EN").value.length != 0) {
$(".formularz").css('visibility', 'hidden').css("position", "absolute");
$('#table-2').dataTable().fnAddData([
"",
document.getElementById("PL").value,
document.getElementById("EN").value,
random,
a,
""]);
$('#table-2 td:first-child').addClass('pierwsza');
$('#table-2 td:last-child').addClass('usun');
document.getElementById("PL").value = "";
document.getElementById("EN").value = "";
} else {
alert("Grupa nie zostala dodana!\nWypelnij dane i sprobuj jeszcze raz!")
}
}
[/code]
i have problems with saving and loading my datatable in local storage, can sb tell what im doing wrong?
this is my all code
[code]
$(document).ready(function () {
$('#table-2').dataTable({
});
$(document).click(function() {
$('#table-2').dataTable( {
"bStateSave": true,
"fnStateSave": function (oSettings, oData) {
localStorage.setItem( 'DataTables_'+window.location.pathname, JSON.stringify(oData) );
},
"fnStateLoad": function (oSettings) {
var data = localStorage.getItem('DataTables_'+window.location.pathname);
return JSON.parse(data);
}
} );
} );
$(document).ready(function () {
var startPosition;
var endPosition;
$("#table-2 tbody").sortable({
cursor: "move",
start: function (event, ui) {
startPosition = ui.item.prevAll().length + 1;
},
update: function (event, ui) {
endPosition = ui.item.prevAll().length + 1;
}
});
});
$(document).ready(function () {
$('#table-2').dataTable({
"sPaginationType": "full_numbers"
});
});
(function () {
var bsa = document.createElement('script');
bsa.type = 'text/javascript';
bsa.async = true;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(bsa);
})();
$(document).ready(function () {
$('.usun').live('click', function () {
$(this).closest('tr').animate({ 'color': '#fff' }, 300, function () {
$(this).remove();
});
});
});
$('.olowek').live('click', function () {
$(this).closest('td').animate({}, 300, function () {
if ($(this).text() == "tak") {
$(this).html("nie")
} else if ($(this).text() == "nie") {
$(this).html("tak")
}
});
});
$(document).ready(function () {
$('.text').editable('save.php', {
type: 'text',
cancel: 'Anuluj',
submit: 'Zapisz',
indicator: '',
width: '100px'
});
})
$(document).ready(function () {
$('#table-2').dataTable();
var ile = $('#table-2').dataTable().fnSettings().fnRecordsTotal();
});
/* Global var for counter */
var giCount = $('#table-2').dataTable().fnSettings().fnRecordsTotal();
$(document).ready(function () {
$('#table-2').dataTable();
});
function aaa() {
$(".formularz").css('visibility', 'visible').css("position", "relative");
}
function bbb() {
$(".formularz").css('visibility', 'hidden').css("position", "absolute");
}
var a;
function fnClickAddRow() {
var random = Math.round(Math.random() * 10);
a = document.getElementById("otwarta").value + "";
$('.usun').live('click', function () {
$(this).closest('tr').animate({ 'color': '#fff' }, 300, function () {
$(this).remove();
});
});
if (document.getElementById("PL").value.length != 0 && document.getElementById("EN").value.length != 0) {
$(".formularz").css('visibility', 'hidden').css("position", "absolute");
$('#table-2').dataTable().fnAddData([
"",
document.getElementById("PL").value,
document.getElementById("EN").value,
random,
a,
""]);
$('#table-2 td:first-child').addClass('pierwsza');
$('#table-2 td:last-child').addClass('usun');
document.getElementById("PL").value = "";
document.getElementById("EN").value = "";
} else {
alert("Grupa nie zostala dodana!\nWypelnij dane i sprobuj jeszcze raz!")
}
}
[/code]
This discussion has been closed.