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
This commit is contained in:
Eric Davis
2008-06-19 16:33:15 -07:00
parent b776098c7d
commit 8295b737a1
2 changed files with 11 additions and 6 deletions
+2 -1
View File
@@ -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, "<label for='deliverable_#{field.to_s}'>#{l_field(field, 'field_')}</label>") +
@@ -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"
))
+9 -5
View File
@@ -35,7 +35,6 @@
</td>
<td>
<%= text_field :deliverable, :cost_per_hour, :size => 7 %>
<%= observe_field('deliverable_cost_per_hour', :function => "new Budget.updateAmounts();") %>
</td>
<td>
</td>
@@ -47,7 +46,6 @@
</td>
<td>
<%= text_field :deliverable, :total_hours, :size => 7 %>
<%= observe_field('deliverable_total_hours', :function => "new Budget.updateAmounts();") %>
</td>
<td class="calculation-column">
<%= content_tag(:span, 0, :class => "budget-calculation", :id => 'variableCost') %>
@@ -60,7 +58,6 @@
</td>
<td>
<%= text_field :deliverable, :fixed_cost, :size => 7 %>
<%= observe_field('deliverable_fixed_cost', :function => "new Budget.updateAmounts();") %>
</td>
<td class="calculation-column">
<%= content_tag(:span, 0, :class => "budget-calculation", :id => 'fixedCost') %>
@@ -81,13 +78,19 @@
</table>
<%= f.hidden_field :budget %>
<%= observe_form('deliverable-form', :function => "new Budget.updateAmounts();", :on => 'blur') %>
</div>
<script type="text/javascript">new Budget.changeType();</script>
<script type="text/javascript">new Budget.updateAmounts();</script>
<script type="text/javascript">
new PeriodicalExecuter(function() {
Budget.updateAmounts();
}, 5);
</script>
<div style="clear:both;"> </div>
</div>
<%= 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);