Sha256: 26cae6f305601f6ffccae939f345c7e4c650251b239073c162bba81ed1f6e450

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

jQuery.ajaxSetup({  
    'beforeSend': function (xhr) {xhr.setRequestHeader("Accept", "text/javascript");}
});

jQuery.fn.submitWithAjax = function() {
  this.submit(function () {
    $.post($(this).attr('action'), $(this).serialize(), null, "script");
    return false;
  });  
};

$(document).ready(function() {
    $("#supplementary_task_party_id").change(function() {
        $.post($(this).attr('data-path')+'?authenticity_token='+encodeURIComponent(window.rails_authenticity_token), $(this).serialize(), null, "script");
    });
    
    toggleIndividualTaskFields();
    $('#supplementary_task_party_attributes_entity_1').live('click', function() {
      toggleIndividualTaskFields();
    });
    toggleCompanyTaskFields();
    $('#supplementary_task_party_attributes_entity_2').live('click', function() {
      toggleCompanyTaskFields();
    });
});

function toggleIndividualTaskFields() {
  if ($('#supplementary_task_party_attributes_entity_1').attr('checked') == true) {
    $('#individual_party').fadeIn('fast');
    $('#party_name').fadeIn('fast');
    $("#party_name label").html('Surname');
    $('#supplementary_task_party_attributes_title').removeAttr("disabled");
    $('#supplementary_task_party_attributes_forename').removeAttr("disabled");
  }
}

function toggleCompanyTaskFields() {
  if ($('#supplementary_task_party_attributes_entity_2').attr('checked') == true) {
    $("#individual_party").hide();
    $('#party_name').fadeIn('fast');
    $("#party_name label").html('Company Name');
    $('#supplementary_task_party_attributes_title').attr("disabled", "disabled");
    $('#supplementary_task_party_attributes_forename').attr("disabled", "disabled");
  }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
head_start-0.1.7 vendor/assets/javascripts/scorpion/supplementary_tasks.js
head_start-0.1.6 vendor/assets/javascripts/scorpion/supplementary_tasks.js
head_start-0.1.5 vendor/assets/javascripts/scorpion/supplementary_tasks.js
head_start-0.1.4 vendor/assets/javascripts/scorpion/supplementary_tasks.js
head_start-0.1.3 vendor/assets/javascripts/scorpion/supplementary_tasks.js
head_start-0.1.2 vendor/assets/javascripts/scorpion/supplementary_tasks.js
head_start-0.1.1 vendor/assets/javascripts/scorpion/supplementary_tasks.js
head_start-0.1.0 vendor/assets/javascripts/scorpion/supplementary_tasks.js