Revision 128f3100
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/ClientJS.pm | ||
---|---|---|
59 | 59 |
data => 3, |
60 | 60 |
removeData => 2, |
61 | 61 |
|
62 |
# Form Events |
|
63 |
focus => 1, |
|
64 |
|
|
62 | 65 |
# ## jstree plugin ## pattern: $.jstree._reference($(<TARGET>)).<FUNCTION>(<ARGS>) |
63 | 66 |
|
64 | 67 |
# Operations on the whole tree |
... | ... | |
93 | 96 |
my $method = $AUTOLOAD; |
94 | 97 |
$method =~ s/.*:://; |
95 | 98 |
return if $method eq 'DESTROY'; |
99 |
return $self->action($method, @args); |
|
100 |
} |
|
101 |
|
|
102 |
sub action { |
|
103 |
my ($self, $method, @args) = @_; |
|
96 | 104 |
|
97 | 105 |
$method = (delete($self->{_prefix}) || '') . $method; |
98 | 106 |
my $num_args = $supported_methods{$method}; |
... | ... | |
263 | 271 |
|
264 | 272 |
=head1 FUNCTIONS EVALUATED ON THE CLIENT SIDE |
265 | 273 |
|
274 |
=head2 GENERIC FUNCTION |
|
275 |
|
|
276 |
All of the following functions can be invoked in two ways: either by |
|
277 |
calling the function name directly on C<$self> or by calling |
|
278 |
L</action> with the function name as the first parameter. Therefore |
|
279 |
the following two calls are identical: |
|
280 |
|
|
281 |
$js->insertAfter($html, '#some-id'); |
|
282 |
$js->action('insertAfter', $html, '#some-id'); |
|
283 |
|
|
284 |
The second form, calling L</action>, is more to type but can be useful |
|
285 |
in situations in which you have to call one of two functions depending |
|
286 |
on context. For example, when you want to insert new code in a |
|
287 |
list. If the list is empty you might have to use C<appendTo>, if it |
|
288 |
isn't you might have to use C<insertAfter>. Example: |
|
289 |
|
|
290 |
my $html = $self->render(...); |
|
291 |
$js->action($list_is_empty ? 'appendTo' : 'insertAfter', $html, '#text-block-' . ($list_is_empty ? 'list' : $self->text_block->id)); |
|
292 |
|
|
293 |
Instead of: |
|
294 |
|
|
295 |
my $html = $self->render(...); |
|
296 |
if ($list_is_empty) { |
|
297 |
$js->appendTo($html, '#text-block-list'); |
|
298 |
} else { |
|
299 |
$js->insertAfter($html, '#text-block-' . $self->text_block->id); |
|
300 |
} |
|
301 |
|
|
302 |
The first variation is obviously better suited for chaining. |
|
303 |
|
|
266 | 304 |
=head2 JQUERY FUNCTIONS |
267 | 305 |
|
268 | 306 |
The following jQuery functions are supported: |
... | ... | |
301 | 339 |
|
302 | 340 |
C<data>, C<removeData> |
303 | 341 |
|
342 |
=item Form Events |
|
343 |
|
|
344 |
C<focus> |
|
345 |
|
|
304 | 346 |
=back |
305 | 347 |
|
306 | 348 |
=head2 JSTREE JQUERY PLUGIN |
Auch abrufbar als: Unified diff
ClientJS: Methoden "focus" und "action"