Cómo crear un formulario modal en páginas estáticas html para almacenar usuarios en rieles

I'm trying to show a modal form window into some static html pages to request a users information and connect this with a Rails application.

I have a dynamic Rails application that save the user's information with a gem Devise in the side of my server.

The creation of modal windows in Rails with Bootstrap seems simple but I do not know if that view can be embedded as javascript into the static pages or if should create the modal form directly in the static page for later send user data to my application rails.

Cualquier idea sería muy apreciada. Gracias por adelantado.

preguntado el 28 de mayo de 14 a las 14:05

I would recommend doing a the form in a static page that submits to your rails application. -

1 Respuestas

You've got three options:

A) render the html for the form out in advance in a hidden div, then just copy that into the modal. B) construct the form in javascript, perhaps using a sort of "blank" form with a few missing details, then render the result into the modal C) use javascript to make a call to the rails back end (which supplies the form html), and when you get it, load it into the modal.

Which choice you use depends on how much dynamic content is in your form. C is the slowest option but simplest in a way since your form will always be built from scratch in rails, which can use the appropriate data. This is suited to a situation where you are looking at lots of records on the page, each of which has a lot of data, and you want to click on one to edit some of the data.

If, for any given page, the form can be generated in rails on initial page render, then you could do A as all of the dynamic elements will be available in your controller in the first place. This is well suited to a page where you are looking at a single record, and want to show an edit form in the modal: because there is only one record to choose between, you always know in advance how to make the form for it.

B is sort of a half-way stage: if you don't know in advance what you will need to load into the form, but the difference between the form "options" is very small then you could fill in the blanks with JS. This is probably the most complicated solution as you'll need to write the JS yourself, but it's more efficient than C.

contestado el 28 de mayo de 14 a las 15:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.