From bec852fed2e75eed06b2c70bfdd27a1d73815600 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 19 Feb 2014 22:02:09 +0000 Subject: [PATCH] - Avoid error if something tries to refresh a destroy()ed nextmatch - Fix not-cleared popup action - Fix timing bug where nextmatch could display old data after an action --- etemplate/js/et2_extension_nextmatch.js | 2 +- etemplate/js/et2_extension_nextmatch_actions.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index e0b34e9c66..efad46c247 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -428,7 +428,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], */ refresh: function(_row_ids, _type) { // Framework trying to refresh, but nextmatch not fully initialized - if(this.controller === null || !this.div.is(':visible')) + if(this.controller === null || !this.div || !this.div.is(':visible')) { return; } diff --git a/etemplate/js/et2_extension_nextmatch_actions.js b/etemplate/js/et2_extension_nextmatch_actions.js index 1ac0e4e69b..a2a4e6cbbe 100644 --- a/etemplate/js/et2_extension_nextmatch_actions.js +++ b/etemplate/js/et2_extension_nextmatch_actions.js @@ -173,11 +173,6 @@ function nm_action(_action, _senders, _target, _ids) return value; } - if(_action.data.nm_action == 'open_popup') - { - // Force nextmatch to re-load affected rows - nextmatch.refresh(idsArr); - } // downloads need a regular submit via POST (no Ajax) if (_action.data.postSubmit) @@ -191,6 +186,12 @@ function nm_action(_action, _senders, _target, _ids) if(_action.data.nm_action == 'open_popup') { + // Force nextmatch to re-load affected rows + // Must be after submit, so server gives us up to date info + // Otherwise, old info will be sent and could overwrite the new, + // depending on timing. + nextmatch.refresh(idsArr); + // Reset action in case there's another one nextmatch.getValue = old_value; } @@ -325,6 +326,7 @@ function nm_open_popup(_action, _ids) button.onclick.apply(button, e.currentTarget); } : function(e) { dialog.dialog("close"); + nm_popup_action = null; } }); });