I have a sign out view and when the User successfully signs out, I want to execute a jQuery function that says "you've been signed out!" in a toast pop up. How do I call the jQuery function from the Django view. I got the jQuery code from here: http://shawntabai.com/wp/2011/09/06/toast-notifications-using-jquery/
VIEWS.PY:
def signout(request):
logout(request)
return HttpResponseRedirect(reverse(index))
jQuery Function stored in my header:
<head>
<script type="text/javascript">
function toast(sMessage)
{
var container = $(document.createElement("div"));
container.addClass("toast");
var message = $(document.createElement("div"));
message.addClass("message");
message.text(sMessage);
message.appendTo(container);
container.appendTo(document.body);
container.delay(100).fadeIn("slow", function()
{
$(this).delay(2000).fadeOut("slow", function()
{
$(this).remove();
});
});
}
</script>
<head>
Can I do something like this:
def signout(request):
logout(request)
return HttpResponseRedirect(reverse(index, "$(document).ready(function(){toast('test');});"))