X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=js%2Finserts.js;h=d85a9062eacdb8265ac5c5811c2042a0a1e96812;hb=6918bb5a9e5505ebdeb1abd93127a68db5ece8b6;hp=b535cd03a361e5841450bf7147785c5213c3a975;hpb=35f960e8c8b1941c5d841ac916ed1468b376ff17;p=fa-stable.git diff --git a/js/inserts.js b/js/inserts.js index b535cd03..d85a9062 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -74,15 +74,15 @@ function _set_combo_input(e) { } } } - }; - e.onkeydown = function(ev) { + }; + e.onkeydown = function(ev) { ev = ev||window.event; key = ev.keyCode||ev.which; if(key == 13) { this.blur(); return false; } - } + } } function _update_box(s) { @@ -99,13 +99,19 @@ function _update_box(s) { } function _set_combo_select(e) { + // When combo position is changed via js (eg from searchbox) + // no onchange event is generated. To ensure proper change + // signaling we must track selectedIndex in onblur handler. + e.setAttribute('_last', e.selectedIndex); e.onblur = function() { if(this.className=='combo') _update_box(this); + if (this.selectedIndex != this.getAttribute('_last')) + this.onchange(); } e.onchange = function() { var s = this; - + this.setAttribute('_last', this.selectedIndex); if(s.className=='combo') _update_box(s); if(s.selectedIndex>=0) { @@ -155,14 +161,14 @@ var inserts = { 'input.ajaxsubmit,input.editbutton,input.navibutton': function(e) { e.onclick = function() { - JsHttpRequest.request(this); - return false; + JsHttpRequest.request(this); + return false; } }, '.amount': function(e) { if(e.onblur==undefined) { - var dec = e.getAttribute("dec"); e.onblur = function() { + var dec = this.getAttribute("dec"); price_format(this.name, get_amount(this.name), dec); }; }