From 8295b737a13f8b23dd07f29481a34c01ede05b39 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 19 Jun 2008 16:33:15 -0700 Subject: [PATCH] Potential fix by calling the update every 5 seconds. Brute force but works. When the FireFox "suggest history" dropbox is used, neither the blur nor change event is fired. I have one solution that covers many of the common cases but fails on some others: * Works - type, down arrow to suggest history, tab * Works - type, down arrow to suggest history, enter, tab * Works - type, click * Works - type, tab * Fails - down arrow to suggest history, enter, tab * Fails - down arrow to suggest history, arrow right, tab I have another solution which is to have a timer update the budget every 5 seconds. This will make sure that even if the blur/change events are not fired, the values will be updated soon. It's brute force but works (in FF so far, still need to test cross-browser). I'm not seeing any performance impact, even with debugging on. #1350 --- app/helpers/deliverables_helper.rb | 3 ++- app/views/deliverables/_form.html.erb | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/helpers/deliverables_helper.rb b/app/helpers/deliverables_helper.rb index 8e6140b..29155e0 100644 --- a/app/helpers/deliverables_helper.rb +++ b/app/helpers/deliverables_helper.rb @@ -2,6 +2,7 @@ module DeliverablesHelper # Helper to generate a form used to calculate the total budget while editing # a Deliverable + # TODO Later: Refactor since observers are not used anymore def field_with_budget_observer_and_totals(form, field) content_tag(:tr, content_tag(:td, "") + @@ -11,7 +12,7 @@ module DeliverablesHelper 0, :class => "budget-calculation", :id => field.to_s + '_subtotal' - ) + observe_field('deliverable_' + field.to_s, :function => "new Budget.updateAmounts();"), + ), :class => "calculation-column" )) diff --git a/app/views/deliverables/_form.html.erb b/app/views/deliverables/_form.html.erb index 0bb38d6..7d38ddd 100644 --- a/app/views/deliverables/_form.html.erb +++ b/app/views/deliverables/_form.html.erb @@ -35,7 +35,6 @@ <%= text_field :deliverable, :cost_per_hour, :size => 7 %> - <%= observe_field('deliverable_cost_per_hour', :function => "new Budget.updateAmounts();") %> @@ -47,7 +46,6 @@ <%= text_field :deliverable, :total_hours, :size => 7 %> - <%= observe_field('deliverable_total_hours', :function => "new Budget.updateAmounts();") %> <%= content_tag(:span, 0, :class => "budget-calculation", :id => 'variableCost') %> @@ -60,7 +58,6 @@ <%= text_field :deliverable, :fixed_cost, :size => 7 %> - <%= observe_field('deliverable_fixed_cost', :function => "new Budget.updateAmounts();") %> <%= content_tag(:span, 0, :class => "budget-calculation", :id => 'fixedCost') %> @@ -81,13 +78,19 @@ <%= f.hidden_field :budget %> + <%= observe_form('deliverable-form', :function => "new Budget.updateAmounts();", :on => 'blur') %> + + +
- - <%= mode == :create ? submit_tag(l(:button_create)) : submit_tag(l(:button_update)) %> <%= link_to_remote l(:label_preview), @@ -124,6 +127,7 @@ Object.extend(BudgetModule.prototype, { }, updateAmounts: function() { + console.log('updateAmounts() called'); if ($('deliverable_type').checked) { // Fixed cost var cost = Budget.toAmount($('deliverable_fixed_cost').value);