I have a page using jquery-ui-dialog. Each time the dialog opens, page contents load in using ajax. Then it binds some event using jquery \"on()\". When the dialog close,
Oscar's answer is incomplete, if inside your partial (view that's loaded via ajax) you attached events using .on(), then you must call .off() before .empty().
Look in the following code, if .off() is not called, events assigned in p1.html via standard .click() handler are removed when calling .empty(), but events assigned in p2.html via .on() are not removed and re assigned each time the partial is loaded.
index.html
Load Partial 1 |
Load Partial 2
p1.html
This is the partial 1
Link 1
Link 2
Link 3
p2.html
This is the partial 2
Link 1
Link 2