Permalink
Browse files

Fixed Ajax.Autocompleter reloading when switching trackers.

Closes #3
  • Loading branch information...
1 parent 55b406d commit 7fdedb01e11f50510d8da1e598bec581531cec8d @pulse00 committed Mar 5, 2011
Showing with 14 additions and 3 deletions.
  1. +11 −2 assets/javascripts/googledocs.js
  2. +3 −1 lib/googledocs_custom_fields_helper_patch.rb
@@ -1,5 +1,5 @@
-document.observe('dom:loaded', function() {
-
+function observeGoogleDocsField() {
+
$$('input.gdocs_input').each(function(element) {
var id = element.identify();
@@ -23,4 +23,13 @@ document.observe('dom:loaded', function() {
element.value = text;
}});
});
+}
+
+
+document.observe('gdocs:load', function(event) {
+ observeGoogleDocsField();
+});
+
+document.observe('dom:loaded', function() {
+ observeGoogleDocsField();
});
@@ -20,7 +20,9 @@ def custom_field_tag_with_google_docs(name, custom_value)
custom_field = custom_value.custom_field
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
field_id = "#{name}_custom_field_values_#{custom_field.id}"
- return text_field_tag(field_name, custom_value.value, {:id => field_id, :class => 'gdocs_input'})
+
+ js = javascript_tag "document.fire('gdocs:load');"
+ return text_field_tag(field_name, custom_value.value, {:id => field_id, :class => 'gdocs_input'}) + js
else
return custom_field_tag_without_google_docs(name, custom_value)
end

0 comments on commit 7fdedb0

Please sign in to comment.