diff --git a/octoprint_smartpreheat/static/js/smartpreheat.js b/octoprint_smartpreheat/static/js/smartpreheat.js index 84366c0..a6bf3a1 100644 --- a/octoprint_smartpreheat/static/js/smartpreheat.js +++ b/octoprint_smartpreheat/static/js/smartpreheat.js @@ -20,9 +20,11 @@ $(function() { }; self.onSettingsBeforeSave = function () { - if (self.scripts_gcode_snippets_doSmartPreheat() != self.settings.scripts.gcode["snippets/doSmartPreheat"]()) { - self.settings.plugins.smartpreheat.scripts_gcode_snippets_doSmartPreheat = self.scripts_gcode_snippets_doSmartPreheat; - self.settings.scripts.gcode["snippets/doSmartPreheat"](self.scripts_gcode_snippets_doSmartPreheat()); + if (self.scripts_gcode_snippets_doSmartPreheat() !== undefined) { + if (self.scripts_gcode_snippets_doSmartPreheat() != self.settings.scripts.gcode["snippets/doSmartPreheat"]()) { + self.settings.plugins.smartpreheat.scripts_gcode_snippets_doSmartPreheat = self.scripts_gcode_snippets_doSmartPreheat; + self.settings.scripts.gcode["snippets/doSmartPreheat"](self.scripts_gcode_snippets_doSmartPreheat()); + } } }; }