manque récupération données ajax

pull/6/head
Fred Tempez 3 years ago
parent 6d200124fd
commit 932b78650a

@ -3327,7 +3327,7 @@ class template {
if($head) {
// Début des entêtes
$html .= '<thead>';
$html .= '<tr>';
$html .= '<tr class="nodrag">';
$i = 0;
foreach($head as $th) {
$html .= '<th class="col' . $cols[$i++] . '">' . $th . '</th>';
@ -3337,12 +3337,12 @@ class template {
$html .= '</thead>';
}
// Début contenu
$html .= '<tbody>';
foreach($body as $tr) {
$html .= '<tr>';
$j = 1;
foreach($body as $tr) {
$html .= '<tr id="item' . ($j++) . '">';
$i = 0;
foreach($tr as $td) {
$html .= '<td " class="pos' . ($i+1) . ' col' . $cols[$i++] . '">' . $td . '</td>';
$html .= '<td class="col' . $cols[$i++] . '">' . $td . '</td>';
}
$html .= '</tr>';
}

@ -0,0 +1 @@
https://github.com/lukasoppermann/html5sortable

@ -16,9 +16,10 @@ class gallery extends common {
public static $actions = [
'config' => self::GROUP_MODERATOR,
'filter' =>self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'dirs' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR
];
@ -44,8 +45,6 @@ class gallery extends common {
public function config() {
// Liste des galeries
$galleries = $this->getData(['module', $this->getUrl(0)]);
$countGalleries = count($this->getData(['module',$this->getUrl(0)]));
if($galleries) {
foreach($galleries as $galleryId => $gallery) {
// Erreur dossier vide
@ -58,9 +57,6 @@ class gallery extends common {
else {
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . ' (dossier introuvable)</span>';
}
// Ordre des galeries
// Element 0 chaine vide
$galeryOrder = range(1,count($this->getData(['module',$this->getUrl(0)])));
// Met en forme le tableau
self::$galleries[] = [
$gallery['config']['name'],
@ -99,10 +95,25 @@ class gallery extends common {
// Valeurs en sortie
$this->addOutput([
'title' => 'Configuration du module',
'view' => 'config'
'view' => 'config',
'vendor' => [
'tablednd'
]
]);
}
/**
* Fonction AJAX tri des galeries
*/
public function filter() {
$data = $_POST['data'];
var_dump(json_decode($data));
var_dump($_POST);
die();
}
/**
* Suppression
*/

@ -0,0 +1,3 @@
[
"tablednd.min.js"
]

@ -0,0 +1 @@
https://github.com/isocra/TableDnD

File diff suppressed because one or more lines are too long

@ -67,15 +67,25 @@ directoryDOM.on("change", function() {
* Tri dynamique de la galerie
*/
$( document ).ready(function() {
var $tbody = $('#galleryTable tbody');
$tbody.find('tr').sort(function (a, b) {
var tda = $(a).find('td.pos3:eq(0)').text();
var tdb = $(b).find('td.pos3:eq(0)').text();
// if a < b return 1
return tda > tdb ? 1
// else if a > b return -1
: tda < tdb ? -1
// else they are equal - return 0
: 0;
}).appendTo($tbody);
$("#galleryTable").tableDnD({
onDrop: function(table, row) {
console.log($.tableDnD.serialize());
var url= <?php echo json_encode(helper::baseUrl() . $this->getUrl(0) . '/filter'); ?>;
/*url = "http://localhost/ZwiiCMS/?galeries/filter"; */
$.ajax({
url: url,
data: $.tableDnD.serialize(),
type: "POST",
success: function (data) {
// Je charge les données dans box
alert("ok");
},
// La fonction à appeler si la requête n'a pas abouti
error: function() {
// J'affiche un message d'erreur
alert("Désolé, aucun résultat trouvé.");
}
});
}
});
});
Loading…
Cancel
Save