eldarion/bootstrap-ajax — pull request #13 by jamstooks (2012-10-29 07:26:49+00:00)
Title: Adding support for parent modals

This patch adds a `data-parent-modal` property to the form which will automatically close the identified modal.

Example:

×

Edit Request

....

There is a catch. We don't want to close the modal if there are errors, so the view will need to provide an `errors` value in the returned JSON. Of course, this only applies if you are using the new `data-parent-modal` so backwards compatibility would be preserved.

def form_invalid(self, form):
data = {
"html": render_to_string(
self.get_template_names(),
self.get_context_data(form=form),
context_instance=RequestContext(self.request)
),
"errors": True
}
return HttpResponse(json.dumps(data), mimetype="application/json")