%def .page>
Here we illustrate a few HTML::Prototype
functions, namely the draggable_element, and
drop_receiving_element. The first draggable text element will
revert to its former position once it it dropped. The second
element will stay put, (and make quite a mess). A drop onto the
first destination will send an Ajax Request to the server, but
no response is displayed. A drop onto the second destination
will send an Ajax Request to the server, and display the
response (a YAML Dump of the arguments) in the div to the right
of the dropzone
This (1) text can be dragged and will revert
This (2) text can be dragged will not revert
The text can be dropped here
but will not update div at right
The text can be dropped here
and will update div at right
This span may be updated when text is dropped.
% $m->print($p->draggable_element
% ('myUpdate1',{
% revert => 1
% }));
% $m->print($p->draggable_element
% ('myUpdate2',{
% }));
% $m->print($p->drop_receiving_element
% ('myUpdate3',{
% url => $m->request_comp->path . '?drop=1',
% }));
% $m->print($p->drop_receiving_element
% ('myUpdate4',{
% url => $m->request_comp->path . '?drop=1',
% update => 'myUpdate'
% }));
<& view_source , caller => 'self' &>
%def>
% ################################################################
<%init>
$p = HTML::Prototype->new();
if (exists $ARGS{drop}) {
my $response = <
At @{[scalar localtime(time)]}
Server Received:
@{[YAML::Dump(\%ARGS)]}
END
$m->print($response);
} else {
$m->comp('.page');
}
%init>
<%shared>
my $p;
%shared>