clear overlay-message via ajax

This commit is contained in:
Oskar Hahn 2012-07-04 03:21:03 +02:00
parent ad8d5585f1
commit 03fe1f84dd
3 changed files with 14 additions and 5 deletions

View File

@ -84,6 +84,7 @@ $(function() {
} }
$( "#iframe" ).css('zoom', '0.25'); $( "#iframe" ).css('zoom', '0.25');
} }
// activate an element to show it on projector // activate an element to show it on projector
$('.activate_link').click(function(event) { $('.activate_link').click(function(event) {
event.preventDefault(); event.preventDefault();
@ -183,7 +184,10 @@ $(function() {
}); });
}); });
$('#overlay-form').ajaxForm(function() { $('#overlay_message').ajaxForm({
alert("Thank you for your comment!"); dataType: 'json',
success: function(data) {
$('#overlay_message_text').val(data['overlay_message']);
}
}); });
}); });

View File

@ -1,8 +1,8 @@
{% load staticfiles %} {% load staticfiles %}
{% load i18n %} {% load i18n %}
{% load tags %} {% load tags %}
<form id="overlay-form" action="" method="post" style="display:inline">{% csrf_token %} <form id="overlay_message" action="" method="post" style="display:inline">{% csrf_token %}
<input name='message_text' type='text' style='width: 40%' value="{% get_config 'projector_message' %}"> <input id="overlay_message_text" name='message_text' type='text' style='width: 40%' value="{% get_config 'projector_message' %}">
<button type="submit" class="button" name='message'> <button type="submit" class="button" name='message'>
<span class="icon ok">{% trans 'Apply' %}</span> <span class="icon ok">{% trans 'Apply' %}</span>
</button> </button>

View File

@ -65,9 +65,14 @@ class ControlView(TemplateView, AjaxMixin):
overlay.active = False overlay.active = False
overlay.save() overlay.save()
if request.is_ajax(): if request.is_ajax():
return ajax_get(request, *args, **kwargs) return self.ajax_get(request, *args, **kwargs)
return self.get(request, *args, **kwargs) return self.get(request, *args, **kwargs)
def get_ajax_context(self, **kwargs):
return {
'overlay_message': config['projector_message'],
}
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(ControlView, self).get_context_data(**kwargs) context = super(ControlView, self).get_context_data(**kwargs)