Revision 2b950963
Von Bernd Bleßmann vor mehr als 8 Jahren hinzugefügt
js/autocomplete_customer.js | ||
---|---|---|
100 | 100 |
} |
101 | 101 |
} |
102 | 102 |
|
103 |
function handle_changed_text(callbacks) { |
|
104 |
$.ajax({ |
|
105 |
url: 'controller.pl?action=CustomerVendor/ajaj_autocomplete', |
|
106 |
dataType: "json", |
|
107 |
data: $.extend( ajax_data($dummy.val()), { prefer_exact: 1 } ), |
|
108 |
success: function (data) { |
|
109 |
if (data.length == 1) { |
|
110 |
set_item(data[0]); |
|
111 |
if (callbacks && callbacks.match_one) callbacks.match_one(data[0]); |
|
112 |
} else if (data.length > 1) { |
|
113 |
state = STATES.UNDEFINED; |
|
114 |
if (callbacks && callbacks.match_many) callbacks.match_many(data); |
|
115 |
} else { |
|
116 |
state = STATES.UNDEFINED; |
|
117 |
if (callbacks &&callbacks.match_none) callbacks.match_none(); |
|
118 |
} |
|
119 |
annotate_state(); |
|
120 |
} |
|
121 |
}); |
|
122 |
}; |
|
123 |
|
|
103 | 124 |
$dummy.autocomplete({ |
104 | 125 |
source: function(req, rsp) { |
105 | 126 |
$.ajax($.extend(o, { |
... | ... | |
134 | 155 |
} else if (state == STATES.PICKED) { |
135 | 156 |
return true; |
136 | 157 |
} |
137 |
if (event.which == KEY.TAB) event.preventDefault(); |
|
138 |
$.ajax({ |
|
139 |
url: 'controller.pl?action=CustomerVendor/ajaj_autocomplete', |
|
140 |
dataType: "json", |
|
141 |
data: $.extend( ajax_data($dummy.val()), { prefer_exact: 1 } ), |
|
142 |
success: function (data) { |
|
143 |
if (data.length == 1) { |
|
144 |
set_item(data[0]); |
|
145 |
if (event.which == KEY.ENTER) |
|
146 |
$('#update_button').click(); |
|
147 |
} else { |
|
148 |
} |
|
149 |
annotate_state(); |
|
150 |
} |
|
151 |
}); |
|
152 |
if (event.which == KEY.ENTER) |
|
158 |
if (event.which == KEY.TAB) { |
|
159 |
event.preventDefault(); |
|
160 |
handle_changed_text(); |
|
161 |
} |
|
162 |
if (event.which == KEY.ENTER) { |
|
163 |
handle_changed_text({ |
|
164 |
match_one: function(){$('#update_button').click();}, |
|
165 |
}); |
|
153 | 166 |
return false; |
167 |
} |
|
154 | 168 |
} else { |
155 | 169 |
state = STATES.UNDEFINED; |
156 | 170 |
} |
157 | 171 |
}); |
158 | 172 |
|
173 |
$dummy.on('paste', function(){ |
|
174 |
setTimeout(function() { |
|
175 |
handle_changed_text(); |
|
176 |
}, 1); |
|
177 |
}); |
|
178 |
|
|
159 | 179 |
$dummy.blur(function(){ |
160 | 180 |
window.clearTimeout(timer); |
161 | 181 |
timer = window.setTimeout(annotate_state, 100); |
Auch abrufbar als: Unified diff
CustomVendorPicker: Auch auf Paste-Events reagieren.
Siehe auch commit 2cf7a2cd78d812d917fb4c92f8ee57f6a32f3685
(PartPicker: Auch auf Paste-Events reagieren.)