From c23e497c424a102c05fbdb7218b2a9af141b30e9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 9 Jan 2012 18:46:37 +0000 Subject: [PATCH] Avoid an AJAX query if the watchers form is already loaded. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8593 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/watchers_controller.rb | 1 + app/views/watchers/_watchers.html.erb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 1a1935d0d..8a4ce5286 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -42,6 +42,7 @@ class WatchersController < ApplicationController render :update do |page| page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched} page << "showModal('ajax-modal', '400px');" + page << "$('ajax-modal').addClassName('new-watcher');" end end end diff --git a/app/views/watchers/_watchers.html.erb b/app/views/watchers/_watchers.html.erb index 1f40707be..29cf7539b 100644 --- a/app/views/watchers/_watchers.html.erb +++ b/app/views/watchers/_watchers.html.erb @@ -5,7 +5,8 @@ :action => 'new', :object_type => watched.class.name.underscore, :object_id => watched}, - :method => 'get' %> + :method => 'get', + :before => "if ($('ajax-modal').hasClassName('new-watcher')) {showModal('ajax-modal'); return false;}" %> <% end %>