refresh javascript using require

Solutions on MaxInterview for refresh javascript using require by the best coders in the world

showing results for - "refresh javascript using require"
Valentina
10 May 2019
1<body>
2  <p id="contents">Nothing loaded.</p>
3  <button id="reload">Reload</button>
4  <script>
5    require.config({	// require's configuration
6        baseUrl: "./js",
7        paths: {
8            jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min', // file path
9        }
10    });
11    require(["jquery"], function ($) {
12        var $contents = $("#contents");
13        function reload() {
14            require.undef("text!../file.html");				 // "clear" the required code
15            require(["text!../file.html"], function (file) { // re-require the code
16                $contents.empty();		// your optional code (can be omitted) by just using:
17                $contents.append(file); // require(["text!../file.html"]);
18            });
19        }
20        $("#reload").click(reload);  // call the refresh function in a button or another function
21    });
22  </script>
23</body>
similar questions
queries leading to this page
refresh javascript using require