A
A
Andrey2019-07-22 12:45:08
JavaScript
Andrey, 2019-07-22 12:45:08

How to implement remote: true for react (rails)?

I create the form like this:

= form_for Review.new do |f|
  = react_component "Popups/ReviewPopup", {name: "review-popup"}

Inside Popups/ReviewPopupI have form fields with the required name .
And when you click on the submit happens:
<button
    onClick={e => {
      onClick(e);
      e.preventDefault();
    }}
    className="button popup-footer__button"
  >
    Отправить
</button>

After that, without reloading, the data from the form should be sent and a message should appear in the browser.
In general, with normal dispatch (if you comment out onClick(e); e.preventDefault();), everything works fine. But it's not entirely clear how to implement remote: true . Moreover, I would like to implement exactly the remote: true behavior , and not to catch the data from the fields when clicking and send them using axios to the server.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question