From 4cd10145af6e8cebcce9f9fc0c8e2e39ce8b64a6 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 5 Feb 2015 11:31:54 -0300 Subject: [PATCH] Fix custom fields after merge with master --- app/helpers/application_helper.rb | 2 +- public/javascripts/manage-custom-fields.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 67ed8fd..7ca09af 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1327,7 +1327,7 @@ module ApplicationHelper end else radios = templates.map do |template| - content_tag('li', labelled_radio_button(link_to(template.name, template.url, :target => '_blank'), "#{field_name}[template_id]", template.id, environment.is_default_template?(template))) + content_tag('li', labelled_radio_button(link_to(template.name, template.url, :target => '_blank'), "#{field_name}[template_id]", template.id, environment.is_default_template?(template), :onchange => 'show_fields_for_template(this);')) end.join("\n") content_tag('div', content_tag('label', _('Profile organization'), :for => 'template-options', :class => 'formlabel') + diff --git a/public/javascripts/manage-custom-fields.js b/public/javascripts/manage-custom-fields.js index b12acb5..1d660ca 100644 --- a/public/javascripts/manage-custom-fields.js +++ b/public/javascripts/manage-custom-fields.js @@ -73,7 +73,7 @@ function add_new_field() { function show_fields_for_template(element) { jQuery('div#signup-form-custom-fields div.formfieldline').remove(); - var selected_template = element.options[element.selectedIndex].value; + var selected_template = jQuery(element).attr('value'); jQuery.ajax({ type: "GET", url: "/account/custom_fields_for_template", @@ -99,3 +99,6 @@ function show_fields_for_template(element) { }); } +jQuery(document).ready(function($) { + show_fields_for_template($('#template-options input[type=radio]:checked')); +}); -- libgit2 0.21.2