From 9a73568c7a714e37a266f9d53c269ed5b7b3432f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 19 May 2016 22:42:28 +0100 Subject: [PATCH] Ensure node field change handlers are invoked after editprepare --- editor/js/ui/editor.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 165a58d2b..8ef14b61f 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -301,8 +301,10 @@ RED.editor = (function() { * @param prefix - the prefix to use in the input element ids (node-input|node-config-input) */ function attachPropertyChangeHandler(node,definition,property,prefix) { - $("#"+prefix+"-"+property).change(function() { - validateNodeEditor(node,prefix); + $("#"+prefix+"-"+property).change(function(event,skipValidation) { + if (!skipValidation) { + validateNodeEditor(node,prefix); + } }); } @@ -399,6 +401,20 @@ RED.editor = (function() { if (definition.oneditprepare) { definition.oneditprepare.call(node); } + // Now invoke any change handlers added to the fields - passing true + // to prevent full node validation from being triggered each time + for (var d in definition.defaults) { + if (definition.defaults.hasOwnProperty(d)) { + $("#"+prefix+"-"+d).trigger("change",[true]); + } + } + if (definition.credentials) { + for (d in definition.credentials) { + if (definition.credentials.hasOwnProperty(d)) { + $("#"+prefix+"-"+d).trigger("change",[true]); + } + } + } validateNodeEditor(node,prefix); }