हल किसी और को एक ही समस्या के साथ कुश्ती के लिए, यह railscast
पर देखने के लिए यहाँ कैसे मैं activeadmin में एक से अधिक गतिशील चयन मेनू लागू किया है :
कॉन्फ़िगर/प्रारंभकर्ता/active_admin.rb
config.register_javascript 'exam_registrations.js.coffee'
एप्लिकेशन/व्यवस्थापक/exam_registrations.rb
form do |f|
f.inputs "Exam Registration Details" do
f.input :user_id, :label => 'Teacher', :as => :select, :collection => User.where(:admin => 'false', :active => true).order(:name), :include_blank => true
f.input :student_id, :hint => 'Students grouped by teacher names', :as => :select, :collection => option_groups_from_collection_for_select(User.where(:admin => false, :active => true).order(:name), :students, :name, :id, :name)
f.input :lesson_id, :hint => 'Lessons grouped by student names', :as => :select, :collection => option_groups_from_collection_for_select(Student.where(:active => true).order(:name), :lessons, :name, :id, :name)
end
f.buttons
end
एप्लिकेशन/आस्तियों/javascripts/exam_registrations.js.coffee
#first menu
jQuery ->
$('#exam_registration_student_id').parent().hide()
students = $('#exam_registration_student_id').html()
$('#exam_registration_user_id').change ->
user = $('#exam_registration_user_id :selected').text()
escaped_user = user.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1')
options = $(students).filter("optgroup[label='#{escaped_user}']").html()
if options
$('#exam_registration_student_id').html(options)
$('#exam_registration_student_id').parent().show()
else
$('#exam_registration_student_id').empty()
$('#exam_registration_lesson_id').empty()
# second menu
$('#exam_registration_lesson_id').parent().hide()
lessons = $('#exam_registration_lesson_id').html()
$('#exam_registration_student_id').click ->
student = $('#exam_registration_student_id :selected').text()
escaped_student = student.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1')
options = $(lessons).filter("optgroup[label='#{escaped_student}']").html()
if options
$('#exam_registration_lesson_id').html(options)
$('#exam_registration_lesson_id').parent().show()
else
$('#exam_registration_lesson_id').empty()
पुनः आरंभ सर्वर और मेनू काम !
जानकारी के लिए धन्यवाद, यह मामूली परिवर्तन के बाद मेरे लिए काम किया। 'config.register_javascript 'exam_registrations'' – blotto
खुशी है कि मैं मदद कर सकता हूं! –
@ रायन.ले: क्या आप कृपया http://stackoverflow.com/questions/28187354/active-admin-populate-one-of-the-second-drop-down-after-first पर एक नज़र डालें – inquisitive