Ajax popup using Ruby on Rails

This is a fairly simple question, but I cannot find a good answer for it. I have a page in my Rails application where there are many objects that can be tagged. Pressing the flag button should display a small box with confirmation, small form, etc. The problem is that I cannot figure out how to do this using RJS templates.

I used page.insert_html, but this requires an identifier. To do this, I had to assign every thing that could be marked with a unique identifier. This does not seem very clean and still leaves me thinking about displaying only one shape and that the field disappears when applied. Is there a simpler solution to this problem? I really want to create something similar to the checkboxes that appear on SO for the flag. Sorry, I'm relatively new to RJS templates. Thanks.

+4
source share
2 answers

You can do this with jQuery facebox . It’s best not to do this in rjs, but in unobtrusive javascript that where everyone moves these days, it’s much cleaner. You can attach a facebox to your links and then click to open the form in a popup window.

Then in your popup you can make your form and redirect or whatever. The user can only click on it, as when a pop-up window opens an inscription, over which an inscription will be imposed, so clicking on it outside it has no effect or closes the form (I think you select in the config).

Sounds like a way.

+4
source

jQuery UI also has a Dialog widget that works great for this kind of thing. This is a good widget, and you can customize your jQuery user interface library to include (or exclude if you want finer javascript to be transmitted in the browser) other convenient widgets (accordion, progressbar, etc.)

Check out Dialog examples in jQuery Dialog

+2
source

All Articles