Situation: You are trying to test some javascript at the middle/end of some long process (e.g. a long painful multiustep form) and instead reloading the page and filling out the form again you'd like some way to dynamically reload your script.
My rudimentary solution :
$(document).ready( function() {
$("#downloadPdf").click( function(e) {
var url = '/teachers/pdf.js';
var success;
// unbind the current click
$("#downloadPdf").unbind('click');
// reload your script
$.ajax({
url: url,
dataType: 'script',
success: success
});
// this is the regular part of your code
})
Obviously this is easy to do if you have not very much code, but if you have a lot more code I could see this getting messy. Any better suggestions on how to make this work?