`
skyline
  • 浏览: 1538 次
  • 性别: Icon_minigender_1
  • 来自: 外婆家的铜锣湾
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

text_field_with_auto_complete

阅读更多
今天在自己的项目里试了一下rails 的 text_field_with_auto_complete.
看完书上的例子之后感觉挺简单。按部就班的就开始了。
可是在自己的firefox上怎么也不行。用firebug察看了生成的xhr。发现一切正常。
返回的数据也对,而且firebug,server log都没有什么错误报告。
百思不得其解之后,放弃text_field_with_auto_complete.自己一步一步的写。
text_field, div , javascript, server 端的method都写好了。
应该万无一失了。可是问题依旧。
又是百思不得其解。
于是试了一下ie 6 和 ie 7,发现两种方法都可以工作。
然后就把注意力放在浏览器上了。
实在不明白firefox 和 ie 的内核到底有什么不同。但是同样的rhtml却生成了不同的html.
用书上的code从新试了一下。结果依然。

rhtml:
  <%# codecite autocomplete %>
  
  <p><label for="user_favorite_language">Favorite language</label><br/>
  <%= text_field 'user', 'favorite_language' %></p>   
  <div class="auto_complete" 
       id="user_favorite_language_auto_complete"></div>
  <%= auto_complete_field :user_favorite_language,   
        :url=>{:action=>'autocomplete_favorite_language'}, :tokens => ',' %>
  
  <%# codecite autocomplete %>


html in IE:
  <p><label for="user_favorite_language">Favorite language</label><br/>
  <input id="user_favorite_language" name="user[favorite_language]" size="30" type="text" value="java" /></p>   
  <div class="auto_complete" 
       id="user_favorite_language_auto_complete"></div>
  <script type="text/javascript">
//<![CDATA[
var user_favorite_language_auto_completer = new Ajax.Autocompleter('user_favorite_language', 'user_favorite_language_auto_complete', '/user/autocomplete_favorite_language', {tokens:','})
//]]>
</script>


html in Firefox:
   <p><label for="user_favorite_language">Favorite language</label><br/>
  <input type="text" value="java" size="30" name="user[favorite_language]" id="user_favorite_language" autocomplete="off"/><p>   
    <div class="auto_complete" 
          id="user_favorite_language_auto_complete"></div>
     <script type="text/javascript">
     //<![CDATA[
     var user_favorite_language_auto_completer = new Ajax.Autocompleter('user_favorite_language', 'user_favorite_language_auto_complete', '/user/autocomplete_favorite_language', {tokens:','})
     //]]>
     </script>


firefox里多了一个 autocomplete=off。不知道为什么会这样。
尽管发现了区别,可还是不明白。因为书上说要先把浏览器的autocomplete关掉。所以我认为这不是什么错误啊。

继续百思,希望求解。

分享到:
评论
1 楼 Stainlesssteel 2007-09-19  
看 auto_complete_macros_helper.rb 里的注释. 里边有解释.

相关推荐

    FormEditText文本验证提示

    date: checks that the field is a valid date/datetime format ( if customFormat is set, checks with customFormat ) nocheck: It does not check anything except the emptyness of the field. For most of the ...

    8-07-14_MegaCLI for linux_windows

    SCGCQ00475159 (DFCT) - While printing the ldinfo, there are some tabs instead of spaces for indentation so replaced all tabs with spaces. SCGCQ00531245 (ENHREQ) - Display the NCQ enabled/disabled ...

    WPTools.v6.29.1.Pro

    + DeleteField now has optional "Contents" parameter to delete a certain field with contents + the text writer now understand the option -softlinebreaks to create a \n at the end of every line. In ...

    Senfore_DragDrop_v4.1

    Field test 5, released 16-dec-2001 ?1997-2001 Angus Johnson & Anders Melander http://www.melander.dk/delphi/dragdrop/ ------------------------------------------- Table of Contents: ------------------...

    强大的免费的十六进制编辑器

    for complete file and selected block (only if block is currently selected) - Data inspector to view decoded numbers - Built-in script interpreter! Refer to online help for details - Easily works ...

    php.ini-development

    compatibility with older or less security conscience applications. We ; recommending using the production ini in production and testing environments. ; ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    When returning from ftmPanning mode the complete client area repainting will perform. - ADD: Added TFlexPanel.FrostPanFullDoc property. When true then in ftmPanning mode the whole document image ...

    Android代码-TokenAutoComplete

    Planning note If you're already using the library, I'm looking at redesigning some of the core...TokenAutoComplete is an Android Gmail style token auto-complete text field and filter. It's designed to ha

    VB编程资源大全(英文控件)

    that scrolls text&lt;END&gt;&lt;br&gt;81,mtymse.zip This is a control (VB5 with source) that controls every aspect of the mouse&lt;END&gt;&lt;br&gt;82,progbar.zip Uses a picture box to emulate a progress bar&lt;END&gt;&lt;br&gt;83...

    Solr in Action最新完整版

    matched snippet highlighting, field collapsing and search results grouping, spell checking, query auto-complete, querying by functions, and more. RETAIL SELLING POINTS Clearly-written comprehensive ...

    Solr in Action 英文版完整版

    matched snippet highlighting, field collapsing and search results grouping, spell checking, query auto-complete, querying by functions, and more. RETAIL SELLING POINTS Clearly-written comprehensive ...

    Visual C++ 编程资源大全(英文源码 其它)

    (1KB)&lt;END&gt;&lt;br&gt;66,XTrace_src.zip Extended TRACE macros with easy source navigation(3KB)&lt;END&gt;&lt;br&gt;67,AutoSave.zip Add auto-save feature to Visual Studio 6.0.(41KB)&lt;END&gt;&lt;br&gt;68,acomment.zip This ...

    LotusDomino学习笔记(400页涵盖代理和公式使用)

    39. Display Rich Text fields in a view 86 40. Auto-Launch a file attachment 87 41. Showing a response count without showing the responses 89 42. 常用的几个按钮收集 91 43. 在WEB上从视图删除文档技巧 93 ...

    Lotus Domino WEB详细 学习笔记

    39. Display Rich Text fields in a view 86 40. Auto-Launch a file attachment 87 41. Showing a response count without showing the responses 89 42. 常用的几个按钮收集 91 43. 在WEB上从视图删除...

    arcgis工具

    Auto-complete polygon 工具生成共享边的多边形,配合snapping environment更好。 10. 画岛图 1).使用任务栏中的sketch工具,当画完外面的一圈时,右键 选择finish part 然后画中间的部分 再右键finish sketch ...

    LotusDomino学习笔记.doc

    Display Rich Text fields in a view - **展示方法**: 通过配置视图列公式来显示富文本字段的内容。 #### 40. Auto-Launch a file attachment - **启动方法**: 在视图中配置列公式,使得点击附件时自动下载或打开...

Global site tag (gtag.js) - Google Analytics