How to pass parameters dynamically to Rails?

0

I have a rather complex problem to the extreme. I need to somehow pass parameters dynamically to the params via javascript, to show / hide some fields in a report on user's request. Below is a screen representation:

I have a form where the user enters the data he wants in the search, with remote: true. Up there I have a container with a group of checkboxes, which is my problem at the moment. The below is where the results are loaded from a partial with a .js.erb file. It is important to mention that only this part recharges.

The box with the checkboxes, is not part of a form, and in my mind neither should. In JavaScript, I have an event attached to each checkbox. When each is deselected, the corresponding field in the result tables is hidden and a hidden field is created and dynamically inserted in the form there on the left. So I can send these parameters via url at the time of submit and hide these fields with a conditional giving a display: none on the lines where the parameter has a value of 1. This works if the user performs the filtering. But if it is not done, the parameters are not sent to the URL and when the pagination is done, the lines that should be hidden appear.

I would like to know if there is a way to send these parameters to the hash params dynamically via AJAX, so everything works correctly with or without filtering ...

    
asked by anonymous 30.10.2014 / 12:31

1 answer

1

I would do it like this: I would put my form wrapping everything up and take the Javascript that adds the hidden fields in the form.

The pagination would be submit buttons with the name the page you want.

With this, each time the user clicks on a new page, they will submit the form and send the pagination parameters as desired.

    
17.11.2014 / 17:40