0

I am developing a single page application. My layout page looks like

<html>
   <head>
      <title>My page</title>
   </head>

   <body>
      <div id="page1"></div>
      <div id="page2"></div>
   </body>
</html>

I need to load two partial views in each div at different instances.

With each partial view, I want to load a javascript file and after removal of that partial view I wanna remove that respective js file too. Is it possible?

2 Answers2

0

Why not set these two partial views as two components and make the javascript files into specified components?

danielx
  • 36
  • 3
0

Here is the code try this

js1.js:

var myFunc = new (function() {

    this.test_one = function() {
        alert('one!');
    };

})();

js2.js:

function test_one(){
 alert('another one');
}

In your view :

<script type="text/javascript" src="js1.js"></script>
<script type="text/javascript" src="js2.js"></script>

<script type="text/javascript">
myFunc.test_one();
test_one();
</script>

hope it may helpful for you.

N.S
  • 139
  • 1
  • 1
  • 13