summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume (ioguix) de Rorthais2010-09-23 00:11:07 +0000
committerGuillaume (ioguix) de Rorthais2010-09-23 00:14:07 +0000
commitc227265ba1a2fb35943402398ff7a4d8666e5ee1 (patch)
treed7a86da2aff32c9dedac2540669708daa2a42312
parent2d34ba1218a8335311f3923080c78cbe2338ec96 (diff)
Fix with auto-complete on insert where list was empty on update when we already have an offset
-rw-r--r--js/ac_insert_row.js36
1 files changed, 18 insertions, 18 deletions
diff --git a/js/ac_insert_row.js b/js/ac_insert_row.js
index 120a5798..cd59e2c5 100644
--- a/js/ac_insert_row.js
+++ b/js/ac_insert_row.js
@@ -14,15 +14,15 @@ function hideAc() {
function triggerAc(ac) {
if (ac) {
jQuery.ppa.attrs
- .keyup(autocomplete)
- .keypress(move)
+ .bind('keyup.ac_action', autocomplete)
+ .bind('focus.ac_action', autocomplete)
+ .bind('keypress.ac_action', move)
.addClass('ac_field');
}
else {
jQuery.ppa.attrs
.removeClass('ac_field')
- .unbind('keyup',autocomplete)
- .unbind('keypress',move);
+ .unbind('.ac_action');
}
}
@@ -125,7 +125,7 @@ function move(event) {
}
}
-/* open/update the value list on keyup event */
+/* open/update the value list */
function autocomplete(event) {
/* if pressing enter, fire a click on the selected line */
@@ -133,7 +133,6 @@ function autocomplete(event) {
if (jQuery.ppa.i > 0) {
jQuery.ppa.fklist.find('tr').eq(jQuery.ppa.i).click();
}
- hideAc();
return false;
}
/* ignoring 38:up and 40:down */
@@ -152,6 +151,11 @@ function autocomplete(event) {
}
/* request the list of possible values asynchronously */
else {
+ /* if we refresh because of a value update,
+ * we reset back to offset 0 so we catch values
+ * if list is smaller than 11 values */
+ if (event.type == 'keyup')
+ jQuery.ppa.o = 0;
openlist(this);
}
@@ -175,17 +179,19 @@ with(jQuery('tr.acline')) {
}
jQuery('#fkprev').live('click', function () {
- jQuery.ppa.o-=11;
+ jQuery.ppa.o -= 11;
/* get the field that is the previous html elt from the #fklist
- * and trigger its keyup to refresh the list */
- jQuery('#fklist').prev().keyup().focus();
+ * and trigger its focus to refresh the list AND actualy
+ * focus back on the field */
+ jQuery('#fklist').prev().focus();
});
jQuery('#fknext').live('click', function () {
- jQuery.ppa.o+=11;
+ jQuery.ppa.o += 11;
/* get the field that is the previous html elt from the #fklist
- * and trigger its keyup to refresh the list */
- jQuery('#fklist').prev().keyup().focus();
+ * and trigger its focus to refresh the list AND actualy
+ * focus back on the field*/
+ jQuery('#fklist').prev().focus();
});
jQuery(document).ready(function () {
@@ -209,12 +215,6 @@ jQuery(document).ready(function () {
if (e.keyCode == 13 && jQuery.ppa.fklist[0].style.display == 'block')
return false;
});
-
- /* open the list when the field get the focus */
- jQuery.ppa.attrs
- .focus(function (e) {
- $(this).keyup();
- });
/* enable/disable auto-complete according to the checkbox */
triggerAc(