0

I have the following jquery method:

(function($){
  $(document).ready(function() {
      $("select[name='publication_type[category]'] ").change(function (){
          alert("It works");

       });

    });
})(jQuery);

It operates on the following ruby code:

select("publication_type", "category", @filters.selections.collect(&:name), :id =>"publication_type" ) 

Each time I choose a different option from the drop down box, the alert method fires twice. The intention is that it should only fire once. Any ideas?

Thanks in advance...

Faisal
  • 19,358
  • 4
  • 30
  • 33
David
  • 1

2 Answers2

0

I don't know about the double alert, but don't use the "change" event. IE does not fire the change event on a select element until it loses focus, not when the value changes.

edit: same goes for radio buttons and checkboxes.

Faisal
  • 19,358
  • 4
  • 30
  • 33
0

I discovered the problem...I had added the javascript file in two places...one in the layout template and another in the view that was being rendered.

David
  • 1