-
-
Save jhgaylor/3148247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def the_display_view(request): | |
form = settingsapp.views.ajax_form(request) | |
our_data_dict = {} | |
our_data_dict['form'] = form | |
... | |
... | |
return HttpResponse('template.html', our_data_dict) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="yourFancyBoxClass"> | |
{% if success %} | |
<h2>It Worked!</h2> | |
{% else %} | |
<form action="{% url ajax_form %}"> | |
{% form %} | |
</form> | |
{% endif %} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".yourLaunchClass").fancybox({onComplete:function (){ | |
//grab this function so that we can pass it back to | |
//`onComplete` of the new fancybox we're going to create | |
var func = arguments.callee; | |
//bind the submit of our new form | |
$('.yourFancyBoxClass form').submit(function(){ | |
//this is strictly cosmetic | |
$.fancybox.showActivity(); | |
var data = $(this).serialize(); | |
var url = $(this).attr('action') | |
//post to the server and when we get a response, | |
//draw a new fancybox, and run this function on completion | |
//so that we can bind the form and create a new fancybox on submit | |
$.post(url, data, function(msg){$.fancybox({content:msg,onComplete:func})}); | |
return false; | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ajax_form(request): | |
context = {} | |
if request.method == "POST": | |
form = myForm(request.POST) | |
if form.is_valid(): | |
form.save() | |
context['success'] = True | |
#### | |
return True | |
#### | |
else: | |
form = WaitingListEntryForm() | |
context['form'] = form | |
return form | |
#return render_to_response("AjaxFancyBox.html", context, context_instance=RequestContext(request)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment