You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Posted this on stackoverflow. Thought it best if I post it here too.
For testing purposes I am trying to remove some amd modules and reload updated versions from the server - with the goal of not refreshing the browser.
I am currently doing the following but the browser still doesn't reload the items from the network.
var scripts = document.getElementsByTagName('script');
var context = require.s.contexts['_'];
for (var key in context.defined) {
if(key.indexOf("tests")>-1){
requirejs.undef(key);
for (var i = scripts.length - 1; i >= 0; i--) {
var script = scripts[i];
var attr = script.getAttribute('data-requiremodule')
if (attr === key){
script.parentNode.removeChild(script);
}
}}
It deletes the references from the context and removes the script tags successfully. But alas...
Does anyone know the mechanism to clear all the references from requirejs?
requirejs.undef() will remove the module from the defined cache, but any existing modules that have been bound to it are not cleared. Is that what you want to do, also remove any modules that depend on the removed module (and modules that depend on that set, and so on)?
If so, then it is better to just start a new requirejs context:
Posted this on stackoverflow. Thought it best if I post it here too.
For testing purposes I am trying to remove some amd modules and reload updated versions from the server - with the goal of not refreshing the browser.
I am currently doing the following but the browser still doesn't reload the items from the network.
var scripts = document.getElementsByTagName('script');
var context = require.s.contexts['_'];
for (var key in context.defined) {
if(key.indexOf("tests")>-1){
requirejs.undef(key);
for (var i = scripts.length - 1; i >= 0; i--) {
var script = scripts[i];
var attr = script.getAttribute('data-requiremodule')
if (attr === key){
script.parentNode.removeChild(script);
}
}}
It deletes the references from the context and removes the script tags successfully. But alas...
Does anyone know the mechanism to clear all the references from requirejs?
Any help much appreciated
http://stackoverflow.com/questions/11899967/require-js-remove-definition-to-force-reload
The text was updated successfully, but these errors were encountered: