javascript と jquery を学習したばかりで、jquery データテーブルの使用に問題があります。
私のデータはphpに2回投稿されました。スクリプトに event.preventDefault を実装して false を返す方法がわかりません。
olistorderproduktdatatable = $("#listorderprodukttable").dataTable({
"bJQueryUI": true, "bPaginate": false, "bFilter": true, "bInfo": false, "bAutoWidth": true, "sDom": 'Rlfrtip',
"bServerSide": true,
"sSearch" :"Filter",
"bDestroy": true,
"sAjaxSource": "share/content/helper/datatablelistorderprodukt.php"
});
$('#listorderprodukttable tbody').delegate("tr", "click", rowClickAddPosition);
function rowClickAddPosition(){
//Welche Zeile wurde selektiert und ID herausfiltern
if (hlr)
$("td:first", hlr).parent().children().each(function(){$(this).removeClass('markrow');});
hlr = this;
$("td:first", this).parent().children().each(function(){$(this).addClass('markrow');});
// You can pull the values out of the row here if required
var a = $("td:first", this).text();
var b = $("td:eq(1)", this).text();
selectedRow = a; //ID der Zeile WICHTIGE VARIABLE!!!
//Abfrage ob ID leer ist, also ob es überhaupt Einträge gibt.
if(selectedRow != "No matching records found"){
$.ajax({
type : 'POST',
url : 'share/content/helper/orderaddposition.php',
cache: false,
data: {
SelectedProdukt : selectedRow,
BestellID : BestellID
},
success: function(data) {
callbackaddposition();
}
});
}
}
イベントをキャッチする方法がわかりません。