How to use text_field via ajax

Asked

Viewed 53 times

0

I am trying to call via ajax a function in a text_field field, I tried it in two ways: 1 - From Undefined method remote_function error.

<%= f.text_field(:data, class: "form-control", :remote => true, :onchange=>remote_function(:url=>{:action=>"fetch_duration"})) %>

2 - From Synthase error

<%= f.text_field(:data, class: "form-control", :remote => true, :onchange=> {:url=>{:action=>"fetch_duration"}}) %>

Does anyone have any example, or link that can help me?

1 answer

0

I think you have to pass the JS code to String for it to run, or a javascript function call that you have implemented.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.