Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jquery - Active Admin, populate one of the second drop down after first

I am using a word to category mapping. A word can be mapped to a category or a type. In database, I have words table, categories table, types table and a join mappings called word_categories which contains the word_id, cat_type (having value either category or type), cat_id (if the cat_type is category the cat_id corresponds to categories table, or if the cat_type is type the cat_id corresponds to the type table).

In active admin keyword_categories.rb i have

form do |f|
  f.inputs do
    if f.object.new_record?
      f.input :word, as: :select, collection: Word.unmapped.pluck(:word)
      f.input :cat_type, as: :select, :collection => ["Type", "Category"]
      if true #here i have to give some logic to select on the basis of the value selected in the first drop down
        f.input :cat_id, as: :select, :collection => Type.pluck(:name)
      else 
        f.input :cat_id, as: :select, :collection => Category.pluck(:name)
      end
    end
  end
  f.actions
end

I followed SO Questions, but i dont understand, how do i return value from the controller to the active admin rb file

I am a newbie to jquery

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...