Created
May 31, 2010 20:42
-
-
Save noahhendrix/420261 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= semantic_form_for (@activity ||= Activity.new) do |f| %> | |
<%= f.inputs :name => "Quickly record what you did" do %> | |
<%= f.input :date, :selected => Date.today, :order => [:month, :day, :year] %> | |
<%= f.input :category, :collection => [ "Office", "Personal", "Sales" ], :label => "Type", :input_html => { :class => "change-form-options" } %> | |
<%= f.inputs :rel => "Sales" do %> | |
<%= f.input :contact_id, :as => :string %> | |
<% end %> | |
<%= f.input :notes %> | |
<%= f.inputs :rel => "Sales Office" do %> | |
<%= f.input :outcome, :collection => [ "In the bag", "Will get them with some effort", "50-50 chance no matter what we do", "Probably won't get their business", "Waste of time" ] %> | |
<%= f.input :next_steps %> | |
<% end %> | |
<% end %> | |
<%= f.submit %> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In some forms the fields change based on change in select | |
$('select.change-form-options').change(function(event){ | |
$select = $(this); //cache the select input | |
value = $select.val(); //save the value in the input | |
$parent_form = $select.parents("form"); //get/cache the form | |
$optional_fieldsets = $parent_form.find("fieldset[rel]"); | |
$optional_fieldsets.hide().filter("[rel~="+value+"]").show(); //~= contains word in attribute somewhere | |
}).change(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment