Ensure node field change handlers are invoked after editprepare

This commit is contained in:
Nick O'Leary 2016-05-19 22:42:28 +01:00
parent acdef87be7
commit 9a73568c7a
1 changed files with 18 additions and 2 deletions

View File

@ -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);
}