Fixed Javascript scope-slip in "display-template-contents-of-entered-template-name"-snippet

MaGeFH

Active member
Affected version
DP10
The template admin:template_modification_edit does feature a javascript snippet to dynamically load the contents of the template into the form, for easy reference.

As soon as I tried to use this for two or more form fields on the same page, it broke a bit. This is due to one variable not being defined as var and thus escaping the function scope and attaching to the global scope. This means that any other inclusions of the script will override this var in the global scope, leaving only the last one.

Easy to fix, replace this:
JavaScript:
updateContents = function(templateName)
with that:
JavaScript:
var updateContents = function(templateName)

:)
 
Top Bottom