function AddAutoCompleteToFields(Bvb_Grid_Event $event) { $subject = $event->getSubject(); $script = "\$(document).ready(function() {"; foreach ($subject->getVisibleFields() as $name) { $script .= "\$(\"input#filter_{$name}\").autocomplete({focus: function(event, ui) " . "{document.getElementById('filter_{$name}').value = ui.item.value }," . " source: '{$subject->getAutoCompleteUrlForFilter($name)}'});\n"; } $script .= "});"; $subject->getView()->headScript()->appendScript($script); }