Source

django-ajax-poll / poll / templates / polls.html

{% load i18n %}
{% if polls %}
{% for p in polls %}
<div id="form-{{p.id}}">
<p><strong>{{p.question}}</strong></p>
<div class="error_field"></div>
<form> 
	{% csrf_token %}
	{% for a in p.get_answers %}
	<p><input type="radio" name="answer" value="{{a.0}}"> {{a.1}}</p>
	{% endfor %}
	<a class="submit" href="#{{p.id}}" id="submit-{{p.id}}"><span>Submit</span></a>
</form>
</div>
<div class="clear">&nbsp;</div>
{% endfor %}
<script>
	// AJAX poll submission    
	$(function() {

		
		$('#poll a.submit').click(function(){
		 var poll_id = $(this).attr('id');
		 var poll_id = poll_id.replace('submit-','')
         //answer_id = $('#form-'+poll_id+' form input[type="radio"]:selected').val();
		 var answer_id = $('#form-'+poll_id+" input[@name='answer']:checked").val();
		 var form_data = false;
		if(typeof answer_id != 'undefined'){
		   post_url = "/poll/submit/" + poll_id+'/'+answer_id;
            $('#form-'+poll_id).slideUp('fast', function(){  
				//$('#latest_work .projects').css('background-image','url('+SITE_URL+'system/pyrocms/themes/vivaaspire/img/loading.gif)');
				//send the request to the server
				$.post(post_url, form_data, function(data, response, xhr) {
					//$('#latest_work .projects').css('background-image','none');
					$('#form-'+poll_id).html(data).slideDown('fast',function(){}); 
                });
				
			});  
		}  
		else{
		   $('#form-'+poll_id+ ' .error_field').html('<p class="error">{% trans "Please choose an answer" %}</p>'); 
		}
		  
	})  
		
	}); 
</script>
{% else %}
<p>{% trans "There are no polls published." %}
{% endif %}
                   
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.