1

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?

1 Answer 1

1

Since you're using a click handler instead of .live(), you could clone the elements that will be effected and remove the old ones before you re-run your edited code

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.