Revision eff6af28
Von Sven Schöling vor mehr als 11 Jahren hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
51 | 51 |
$self->{parts} = SL::DB::Manager::Part->get_all(query => [ @filter ], limit => $limit); |
52 | 52 |
$self->{value} = $::form->{column} || 'description'; |
53 | 53 |
|
54 |
# if someone types something, and hits enter, assume he entered the full name. |
|
55 |
# if something matches, treat that as sole match |
|
56 |
if ($::form->{prefer_exact}) { |
|
57 |
for my $part (@{ $self->{parts} }) { |
|
58 |
if ( lc $part->description eq lc $::form->{term} |
|
59 |
|| lc $part->partnumber eq lc $::form->{term}) { |
|
60 |
$self->{parts} = [ $part ]; |
|
61 |
last; |
|
62 |
} |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
54 | 66 |
$self->render('part/ajax_autocomplete', { layout => 0, type => 'json' }); |
55 | 67 |
} |
56 | 68 |
|
js/autocomplete_part.js | ||
---|---|---|
115 | 115 |
$.ajax({ |
116 | 116 |
url: 'controller.pl?action=Part/ajax_autocomplete', |
117 | 117 |
dataType: "json", |
118 |
data: ajax_data($dummy.val()),
|
|
118 |
data: $.extend( ajax_data($dummy.val()), { prefer_exact: 1 } ),
|
|
119 | 119 |
success: function (data){ |
120 | 120 |
if (data.length == 1) { |
121 | 121 |
set_item(data[0]); |
Auch abrufbar als: Unified diff
Bei tab und enter den ersten full match benutzen. nur wenn der nicht eindeutig ist resetten oder popup öffnen