Chen Kinnrot
Chen Kinnrot

Reputation: 21015

The rails way to maunally submit a remote form with ujs

Rails 5.2.0

Lets say I have a form without a submit button, And I want another event, for example after a input was entered, to trigger the submission, but still enjoy all of ujs features.

what's the best practice here, should I call a method like Rails.ajax ? Or fire event via Rails.fire ? is there any docs related to this issue?

My case is debauncing an input for 1 sec and than submit it.

Upvotes: 3

Views: 666

Answers (1)

renen
renen

Reputation: 451

Not sure there is an official answer, but variants on this work well for me:

onchange: "$(this).closest('form').submit();"

onchange, onblur, onclick. Obviously, that's a jquery solution. But the concept should be clear.

Upvotes: 0

Related Questions