开发者

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

开发者 https://www.devze.com 2023-02-19 09:07 出处:网络
this is my form: <%= form_tag(\'/search/results\', :method => \"get\") do %>   <%= label_tag(:q, \"Search for:\") %>

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 开发者_Python百科field the site wil refresh. how can i do it?


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

精彩评论

暂无评论...
验证码 换一张
取 消