Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

refresh javascript using require

<body>
  <p id="contents">Nothing loaded.</p>
  <button id="reload">Reload</button>
  <script>
    require.config({	// require's configuration
        baseUrl: "./js",
        paths: {
            jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min', // file path
        }
    });
    require(["jquery"], function ($) {
        var $contents = $("#contents");
        function reload() {
            require.undef("text!../file.html");				 // "clear" the required code
            require(["text!../file.html"], function (file) { // re-require the code
                $contents.empty();		// your optional code (can be omitted) by just using:
                $contents.append(file); // require(["text!../file.html"]);
            });
        }
        $("#reload").click(reload);  // call the refresh function in a button or another function
    });
  </script>
</body>
Comment

refresh javascript using require

<body>
  <p id="contents">Nothing loaded.</p>
  <button id="reload">Reload</button>
  <script>
    require.config({	// require's configuration
        baseUrl: "./js",
        paths: {
            jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min', // file path
        }
    });
    require(["jquery"], function ($) {
        var $contents = $("#contents");
        function reload() {
            require.undef("text!../file.html");				 // "clear" the required code
            require(["text!../file.html"], function (file) { // re-require the code
                $contents.empty();		// your optional code (can be omitted) by just using:
                $contents.append(file); // require(["text!../file.html"]);
            });
        }
        $("#reload").click(reload);  // call the refresh function in a button or another function
    });
  </script>
</body>
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript object shallow merge 
Javascript :: variables 2 python .Bartolome sintes Marco 
Javascript :: mongodb hasOwnProperty returns false 
Javascript :: vendor bundle base js and bootstrap min js conflict 
Javascript :: js find place value 
Javascript :: set in Dynamo DB not properly incrementing nodejs lamnda function 
Javascript :: chai expect array without order 
Javascript :: javascript compute heading on too points 
Javascript :: send json object to xsjs 
Javascript :: adding growl delete notifications in vanilla js 
Javascript :: push a new route only triggers URL change but not location change 
Javascript :: elemente alphabetisch sortieren javascript 
Javascript :: angular.json to war 
Javascript :: create javascript array from datalist dynamically 
Javascript :: u017f javascript 
Javascript :: how to create alias in populate moongoose + nodejs 
Javascript :: how to trim dates in react 
Javascript :: reactive forms angular conditional disabling 
Javascript :: onclick show 10 elements 
Javascript :: how to use a script to inject a meta attribute in html 
Javascript :: Google Places select first on Enter 
Javascript :: what does conservatism really mean 
Javascript :: ctx beginpath react 
Javascript :: removeeventlistener not working in class javascript 
Javascript :: smmoth scroll js 
Javascript :: Forbidden message JS 
Javascript :: how to use adminlte in reacts 
Javascript :: stop playing music when page is closed react 
Javascript :: input file selector on button click vuejs 
Javascript :: create react app runtime env 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =