/[drupal]/contributions/modules/advpoll/advpoll-vote.js
ViewVC logotype

Contents of /contributions/modules/advpoll/advpoll-vote.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed Nov 29 02:27:06 2006 UTC (2 years, 11 months ago) by chriskennedy
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
File MIME type: text/javascript
#99252 Cast votes using Ajax; refactor some results handling and split javascript into two main files - patch by fajerstarter and me
1 // $Id$
2
3 if (!Drupal.advpoll) {
4 Drupal.advpoll = {};
5 }
6
7 /*
8 * Submit advpoll forms with ajax
9 */
10 Drupal.advpoll.attachVoteAjax = function() {
11 $("form.advpoll-vote").each(function() {
12 var thisForm = this;
13 var options = {
14 dataType: 'json',
15 after: function(data) {
16 // Remove previous messages
17 $("div.messages").remove();
18 // Remove the voting form if validating passes
19 if (!data.error) {
20 $(thisForm).hide();
21 }
22 // Insert the response (voting result or error message)
23 $(data.response).insertBefore(thisForm);
24 }
25 };
26 // Tell the server we are passing the form values with ajax and attach the function
27 $(this).prepend('<input type="hidden" name="ajax" value="true" />').ajaxForm(options);
28 });
29 }
30
31 Drupal.advpoll.nodeVoteAutoAttach = function() {
32 Drupal.advpoll.attachVoteAjax();
33 }
34
35 if (Drupal.jsEnabled) {
36 $(document).ready(function(){
37 Drupal.advpoll.nodeVoteAutoAttach();
38 });
39 };

  ViewVC Help
Powered by ViewVC 1.1.2