diff options
author | Artur Signell <artur@vaadin.com> | 2013-03-18 21:34:27 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-03-20 15:09:15 +0200 |
commit | e4c9eda51082a443822b66864df2fe14be7dc6d7 (patch) | |
tree | c6d7f6649e4cc2419102d82512d68ef34696475b /WebContent/VAADIN/vaadinBootstrap.js | |
parent | 5ea677d377c96c60fbc546eb2381bb88f2d4b478 (diff) | |
download | vaadin-framework-e4c9eda51082a443822b66864df2fe14be7dc6d7.tar.gz vaadin-framework-e4c9eda51082a443822b66864df2fe14be7dc6d7.zip |
Enable a Vaadin applications to be re-initialized if if has been re-added to the same page (#8350)
Change-Id: I30dbc14f00108fa699694ecd1d37679d8a0dff4b
Diffstat (limited to 'WebContent/VAADIN/vaadinBootstrap.js')
-rw-r--r-- | WebContent/VAADIN/vaadinBootstrap.js | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js index 9e012ae987..81adfcccc6 100644 --- a/WebContent/VAADIN/vaadinBootstrap.js +++ b/WebContent/VAADIN/vaadinBootstrap.js @@ -55,19 +55,45 @@ pendingApps: [] }; }; - + + var isInitializedInDom = function(appId) { + var appDiv = document.getElementById(appId); + if (!appDiv) { + return false; + } + for ( var i = 0; i < appDiv.childElementCount; i++) { + var className = appDiv.childNodes[i].className; + // If the app div contains a child with the class + // "v-app-loading" we have only received the HTML + // but not yet started the widget set + // (UIConnector removes the v-app-loading div). + if (className && className.contains("v-app-loading")) { + return false; + } + } + return true; + }; + window.vaadin = window.vaadin || { initApplication: function(appId, config) { + var testbenchId = appId.replace(/-\d+$/, ''); + if (apps[appId]) { - throw "Application " + appId + " already initialized"; + if (window.vaadin && window.vaadin.clients && window.vaadin.clients[testbenchId] && window.vaadin.clients[testbenchId].initializing) { + throw "Application " + appId + " is already being initialized"; + } + if (isInitializedInDom(appId)) { + throw "Application " + appId + " already initialized"; + } } + log("init application", appId, config); - var testbenchId = appId.replace(/-\d+$/, ''); window.vaadin.clients[testbenchId] = { isActive: function() { return true; - } + }, + initializing: true }; var getConfig = function(name) { |