Hello.
''m banging with a difficult problem I think.
I have a form like this:
- @company.categorizations.each do |categorization|
%tr
= f.semantic_fields_for :categorizations, categorization do |cat|
%td
%b= categorization.category.name
%td
= cat.input :classification, :as => :select, :collection
=> Classification.all,
:member_label =>
:classification_type, :label => false,
:wrapper_html => { :class
=> "company_classification" },
:input_html => { :class =>
"company_select_classification_type" }
%td
.company_categorization_amount
- if categorization.classification
= text_field_tag "classification_amount",
categorization.classification.amount,
:class =>
"company_input_classification_amount",
:disabled => true
- else
= cat.input :amount, :label => false, :wrapper_html
=> { :class => "company_classification" },
:input_html =>
{ :class => "company_input_classification_amount" }
I hava a coffescript code that monitor the change event of the select field.
$(document).on "change",
".company_select_classification_type", ->
$div =
$(this).closest("td").next().find(".company_categorization_amount")
$.get "/classifications/find_amount",
id: $(this).val(), (data) ->
$div.html data
when the select value change I insert in the
".company_categorization_amount" div the code of the file find_amount:
= text_field_tag "classification_amount", @classification.amount,
:class => "company_input_classification_amount".
That work.
If the select value change and it is blank I want to insert
= cat.input :amount.
One for every @company.categorizations.
I don''t know how to do this.
Some help?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.