Destroy javascript tag

1

I have an Asp.Net MVC project structured as follows: Home On the Home page there are several links for other Actions and Controllers , and they return a PartialView that mounts all contents to modal . Home So far so good, the problem is that by closing such a modal, your scripts remain "alive" in some way. Therefore, when opening a new modal that has the same elements of the previously opened modal, the modal scripts that were closed are fired in the new modal. Home Is there any way to permanently "kill" these scripts? Home Maybe by% w / w% of% w / w% w / w%.

    
asked by anonymous 03.09.2015 / 17:00

1 answer

2

No. Everything indicates that your code is full of bad practices.

First, a Partial should not have JavaScript code inside it. The code should be all in View parent, just to avoid this kind of behavior.

Secondly, it is not a good idea to "destroy" HTML code, not least because HTML was not designed to have a state machine inside it, which is what you are proposing to do. There are frameworks that work like this, but the entire application cycle is managed by the framework itself, so you would probably have to reimplement the whole system by following the framework framework .

Third and lastly, if the goal is to have a system behaving more or less as a SPA (Single Page Application), it would be best to exit ASP.NET MVC and go to Web API. It would make even more sense from the point of view of client behavior with the server side.

    
03.09.2015 / 21:52