From 4c61ad22a4bd02dfadbf1449acec85540a774b08 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Tue, 28 Apr 2015 19:02:33 +0200 Subject: [PATCH] Retry loading sandbox through button click. --- static/js/directives/youtubevideo.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/static/js/directives/youtubevideo.js b/static/js/directives/youtubevideo.js index 44021e18..bfd213e5 100644 --- a/static/js/directives/youtubevideo.js +++ b/static/js/directives/youtubevideo.js @@ -106,7 +106,11 @@ define(['require', 'jquery', 'underscore', 'moment', 'text!partials/youtubevideo var initialState = null; var sandboxApi = null; - var createSandboxApi = function() { + var createSandboxApi = function(force) { + if (sandboxApi && force) { + sandboxApi.destroy(); + sandboxApi = null; + } if (!sandboxApi) { var sandboxFrame = $("#youtubeplayer", $element)[0]; @@ -515,6 +519,10 @@ define(['require', 'jquery', 'underscore', 'moment', 'text!partials/youtubevideo } }; + $scope.loadYouTubeAPI = function() { + createSandboxApi(true); + }; + $scope.showYouTubeVideo = function() { createSandboxApi(); $scope.layout.youtubevideo = true;