From 103e0796b74f5e8ba5b2e346a2966da60a05df0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sun, 21 Dec 2014 15:57:23 +0100 Subject: [PATCH] Request available slicers and slicing profiles from backend asynchronously when opening the slicing dialog Should make sure that slicers and new profiles are detected correctly even without reload. Could maybe help with #689 --- src/octoprint/static/js/app/viewmodels/slicing.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/slicing.js b/src/octoprint/static/js/app/viewmodels/slicing.js index 23a18937..7c60c60e 100644 --- a/src/octoprint/static/js/app/viewmodels/slicing.js +++ b/src/octoprint/static/js/app/viewmodels/slicing.js @@ -28,6 +28,7 @@ function SlicingViewModel(loginStateViewModel, printerProfilesViewModel) { self.afterSlicing = ko.observable("none"); self.show = function(target, file) { + self.requestData(); self.target = target; self.file = file; self.title(_.sprintf(gettext("Slicing %(filename)s"), {filename: self.file})); @@ -48,13 +49,18 @@ function SlicingViewModel(loginStateViewModel, printerProfilesViewModel) { && self.profile() != undefined; }); - self.requestData = function() { + self.requestData = function(callback) { $.ajax({ url: API_BASEURL + "slicing", type: "GET", dataType: "json", - success: self.fromResponse - }) + success: function(data) { + self.fromResponse(data); + if (callback !== undefined) { + callback(); + } + } + }); }; self.fromResponse = function(data) {