var handle = '/demos/survey/survey.php', uiCSS = '/demos/survey/style/jquery-ui-1.8.16.custom.css', uiJS = '/demos/survey/javascript/jquery-ui-1.8.16.custom.min.js'; jQuery(function(){ $('').appendTo("head"); $('
').appendTo('body'); if(surveyarr){ $.getScript(uiJS, function(){ $.each(surveyarr, function(i, e){ $('#'+e.container).each(function(){ var me = $(this); me.data('survey', e.id); $.get(handle,{'survey':e.id, 'action':'survey'}, function(response){ me.html(response).triggerHandler('survey_loaded'); $('input:button').button(); }); }); }); /* SET THE VOTE AND RESET ACTION */ $('.reset-btn').live('click', function(){ var parent = $(this).parents('.survey').first(); $('input:checked', parent).prop('checked', false); }); $('.vote-btn').live('click', function(){ var answer = [], parent = $(this).parents('.survey').first(); $('input', parent).attr('disabled', true); $('input:checked', parent).each(function(){ answer.push($(this).val()); }); $.get(handle, {'survey': parent.data('survey'),'answer[]':answer, 'action':'vote'}, function(response){ $('input', parent).attr('disabled', false); if(response.replace(/^\s+/g, '').length){ $( "#survey_return" ).html(response).dialog({modal: true}); } }); }); }); } })