dimanche 18 octobre 2015

Active admin- Displaying 2nd drop down based on first

I have 3 models Dealer, Label, Number

The relations between models dealer and label - habtm, dealr and number - has_many through labels, label and number - has many.

my first drop down to select dealers, based on that 2nd drop down has to display the labels

        f.input :dealer, :input_html => {
      :onchange => "
          var dealer = $(this).val();
          $('#contact_number_id').val(0).find('option').each(function(){
            var $option = $(this),
            isCorrectDealer = ($option.attr('data-dealer') === dealer);  

            $option.prop('hidden',!isCorrectDealer);
          });
        "
      }
    f.input :contact_label, collection: ContactLabel.all.map{ 
      |v| [v.label_name,v.id, {"data-dealer" => v.dealer_id}]
    }

It is not working for me...Please help me with this

Aucun commentaire:

Enregistrer un commentaire