This is branch question of \"Js file not loaded after partial view is refreshed\". The broblem is that if I put my script in to the main view it doesn\'t work in partial. My
Use a delegated event handler:
$(document).on('click', "[data-hide]", function ()
The jQuery selector is only run at event time, so it will work with dynamically added elements.
It works by listening for the event at a non-changing ancestor element (document is the safest default if nothing else is closer/convenient). It then applies the selector to the elements in the bubble-chain. It then applies your event handler function to only the matching elements that caused the event.
This is very efficient compared to connecting event handlers to individual elements and any speed difference is negligible as you simply cannot click fast enough to notice :)