For some reason when I click on a button, my controller and the resulting jquery function gets called twice. Since the js function being called is toggle, this is a problem as it causes the code to jump in and out of view.
Here is the form:
Unseen Notifications: <%= current_user.notification_unseen %> </div>
<%= button_to "show", {:action => "seen", :controller=>"notifications"}, :remote => true %>
Here is the controller:
def seen
respond_to do |format|
format.js
end
end
Here is the jquery:
$("div#notifications").toggle();
$("div#count").html("<%= escape_javascript( render :partial => 'notifications/count')%>");
I am at a loss for why on earth this would possibly happen. I have been very careful not to double click and don't know how to prevent it. Any suggestions would be greatly appreicated.