ajax - MVC PartialViewResult contains Attached JavaScript function calls, causing memory leak -
i have mvc view contains html table. in table cells contain onclick events attached check boxes, , onchange events tied input boxes. these tied standard javascript function calls in .js file.
<input type="text" id="changeactualtimebox{'0'}" onchange="changestarttime()">
when change occurs in cells call associated jquery ajax function via post method , return partialviewresult containing updated html , new model data. new html table(partialview) contains 10 javascript events per row in td tags. if user pulls different date, memory increases 2mb or more depending on size of table returned, 200 rows of data.
i noticed numerous script block functions being stacked each time retrieve new data, these never released memory. instead of attaching onclick , onchange functions way am, there way use jquery , eliminate javascript calls entirely?
you can use jquery on() method instead of attach onclick , onchaneg functions
example:
<div id="partial-view-container"> @{html.renderpartial("viewname");} </div>
in partialview
<input type="text" id="time">
jquery in main view
$('#partial-view-container').on('change','#time',function(){ //do want here // ajax call });
btw, should replace whole table using ajax call, should not cause memroy leak if replace whole partialview
you can try paging reduce data rendered , speed loading time
Comments
Post a Comment