I have the following jquery method:
(function($){
$(document).ready(fu开发者_如何转开发nction() {
$("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...
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.
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.
精彩评论