最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to use onkeyup() method when i am writing my input with "text_field_tag" (ruby on rails) - St

programmeradmin1浏览0评论

this is my form:

<%= form_tag('/search/results', :method => "get") do %>
  <%= label_tag(:q, "Search for:") %>
  <%= text_field_tag(:q) %> 
  <%= submit_tag("Search") %>
<% end %>

i want when i start typing in the text field the site wil refresh. how can i do it?

this is my form:

<%= form_tag('/search/results', :method => "get") do %>
  <%= label_tag(:q, "Search for:") %>
  <%= text_field_tag(:q) %> 
  <%= submit_tag("Search") %>
<% end %>

i want when i start typing in the text field the site wil refresh. how can i do it?

Share asked Mar 24, 2011 at 23:06 galgal 1514 gold badges22 silver badges40 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

If you mean to just add extra HTML attributes to the element generated by text_field_tag, you can pass them as a hash.

<%= text_field_tag(:q, :onkeyup => 'myJSFunctionToHandleStuff()') %> 

Hash arguments other than :disabled, :size, :maxlength, :placeholder are treated just as passthrough HTML attributes onto the generated input element

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论