以下是在 text_field 中。
= f.text_field :title, :size => 50, :onchange => remote_function(:update => :suggestions, :url => {:action => :display_question_search_results})
以下位于 display_questions_search_results.rjs 中。
page.insert_html :bottom, 'suggestions', :partial => 'suggestions'
每当用户键入时,我都想在数据库中搜索与文本字段中的关键字匹配的任何元组。然后,显示这些结果。但是,目前,_suggestions.haml 只包含单词“suggestions!!”。
但是,而不是看到“建议!!” 在suggestions
div 标签中,我得到:
try { Element.insert("suggestions", { bottom: "suggestions!!" }); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.insert(\"suggestions\", { bottom: \"suggestions!!\" });'); throw e }
我一直在试图找出为什么要这样做,但我发现以前提出的问题似乎比我正在做的更复杂......