Revision cb3a2467
Von Sven Schöling vor etwa 13 Jahren hinzugefügt
SL/Template/Plugin/L.pm | ||
---|---|---|
291 | 291 |
) : ''); |
292 | 292 |
} |
293 | 293 |
|
294 |
sub customer_picker { |
|
295 |
my ($self, $name, $value, %params) = @_; |
|
296 |
my $name_e = _H($name); |
|
297 |
|
|
298 |
$self->hidden_tag($name, (ref $value && $value->can('id')) ? $value->id : '') . |
|
299 |
$self->input_tag("$name_e\_name", (ref $value && $value->can('name')) ? $value->name : '', %params) . |
|
300 |
$self->javascript(<<JS); |
|
301 |
function autocomplete_customer (selector, column) { |
|
302 |
\$(function(){ \$(selector).autocomplete({ |
|
303 |
source: function(req, rsp) { |
|
304 |
\$.ajax({ |
|
305 |
url: 'controller.pl?action=Customer/ajax_autocomplete', |
|
306 |
dataType: "json", |
|
307 |
data: { |
|
308 |
column: column, |
|
309 |
term: req.term, |
|
310 |
current: function() { \$('#$name_e').val() }, |
|
311 |
obsolete: 0, |
|
312 |
}, |
|
313 |
success: function (data){ rsp(data) } |
|
314 |
}); |
|
315 |
}, |
|
316 |
limit: 20, |
|
317 |
delay: 50, |
|
318 |
select: function(event, ui) { |
|
319 |
\$('#$name_e').val(ui.item.id); |
|
320 |
\$('#$name_e\_name').val(ui.item.name); |
|
321 |
}, |
|
322 |
})}); |
|
323 |
} |
|
324 |
autocomplete_customer('#$name_e\_name'); |
|
325 |
JS |
|
326 |
} |
|
327 |
|
|
294 | 328 |
sub javascript_tag { |
295 | 329 |
my $self = shift; |
296 | 330 |
my $code = ''; |
Auch abrufbar als: Unified diff
customer_picker
testpage ist zu Dokumentationszwecken noch dabei, aber nicht mehr durch action
erreichbar.