I have a Django form which I load dynamically to a jQuery dialog after a user has clicked a link on a webpage. The href in the link points to a Django page that contains just the form contents, not the whole site layout.
$('#add-note').click(function() { $('#dialog').load($(this).attr('href')).dialog({ title: 'Add a note', modal: true, draggable: false, minWidth: 500, }); return false; });
This works fine if the user submits a form that validates in the backend. However, if the form contains validation errors, Django forwards the browser back to the form page, which in this case is not actually the page the user was viewing at the moment.
See, the user was on a totally different page and the form was just dynamically loaded to the jQuery dialog. So the question is, what would be the best way to handle this kind of situation? How do I open the form with validation errors back in to the dialog and not the form page itself?
All help appreciated greatly!