Revision 3c0769d8
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/Template/Plugin/L.pm | ||
---|---|---|
410 | 410 |
} |
411 | 411 |
JAVASCRIPT |
412 | 412 |
|
413 |
my $stop_event = ''; |
|
414 |
|
|
413 | 415 |
if ($params{url} && $params{with}) { |
414 | 416 |
my $as = $params{as} || $params{with}; |
415 | 417 |
my $filter = ".filter(function(idx) { return this.substr(0, " . length($params{with}) . ") == '$params{with}'; })"; |
416 | 418 |
$filter .= ".map(function(idx, str) { return str.replace('$params{with}_', ''); })"; |
417 | 419 |
|
420 |
$stop_event = <<JAVASCRIPT; |
|
421 |
\$.post('$params{url}', { '${as}[]': \$(\$('${selector}').sortable('toArray'))${filter}.toArray() }); |
|
422 |
JAVASCRIPT |
|
423 |
} |
|
424 |
|
|
425 |
if (!$params{dont_recolor}) { |
|
426 |
$stop_event .= <<JAVASCRIPT; |
|
427 |
\$('${selector}>*:odd').removeClass('listrow1').removeClass('listrow0').addClass('listrow0'); |
|
428 |
\$('${selector}>*:even').removeClass('listrow1').removeClass('listrow0').addClass('listrow1'); |
|
429 |
JAVASCRIPT |
|
430 |
} |
|
431 |
|
|
432 |
if ($stop_event) { |
|
418 | 433 |
$attributes{stop} = <<JAVASCRIPT; |
419 | 434 |
function(event, ui) { |
420 |
\$.post('$params{url}', { '${as}[]': \$(\$('${selector}').sortable('toArray'))${filter}.toArray() });
|
|
435 |
${stop_event}
|
|
421 | 436 |
return ui; |
422 | 437 |
} |
423 | 438 |
JAVASCRIPT |
... | ... | |
686 | 701 |
dragable, and clicks through to underlying elements like inputs or |
687 | 702 |
links might not work. |
688 | 703 |
|
704 |
=item C<dont_recolor> |
|
705 |
|
|
706 |
If trueish then the children will not be recolored. The default is to |
|
707 |
recolor the children by setting the class C<listrow0> on odd and |
|
708 |
C<listrow1> on even entries. |
|
709 |
|
|
689 | 710 |
=back |
690 | 711 |
|
691 | 712 |
Example: |
... | ... | |
704 | 725 |
<table> |
705 | 726 |
|
706 | 727 |
[% L.sortable_element('#thing_list tbody', |
707 |
'url' => 'controller.pl?action=SystemThings/reorder', |
|
708 |
'with' => 'thingy', |
|
709 |
'as' => 'thing_ids') %] |
|
728 |
url => 'controller.pl?action=SystemThings/reorder', |
|
729 |
with => 'thingy', |
|
730 |
as => 'thing_ids', |
|
731 |
recolor_rows => 1) %] |
|
710 | 732 |
|
711 | 733 |
After dropping e.g. the third element at the top of the list a POST |
712 | 734 |
request would be made to the C<reorder> action of the C<SystemThings> |
Auch abrufbar als: Unified diff
Automatisches Neu-Einfärben nach Drag&Drop