Jseb
Jseb

Reputation: 1934

Rails Pop up windows before saving to database

I am a bit unsure on how to tackle this problem. My goals is to allow user to write an article and upon submit a windows would then verify with the parameter of the article if articles exist or some are simular according to x parameters. Show them to the user in a pop windows and allow user to determine if he wants to combine the article such has picture to a previous existing article or to create his own one.

The issue i have his how can i create a pop up windows, without been block by most current browser, if impossible would my alternative be

My next task his how could i combine, or not, should i create a hidden field and look in the controller if combine then this else this???

Thanks for any help, tutorial links, and suggestion are appreciated. My really main question dough his can it be done with pop up windows! Aka Javascript black surrounding does work too, but not sure if allowed and how can it be achieved!

Upvotes: 0

Views: 766

Answers (4)

Prasanna Natarajan
Prasanna Natarajan

Reputation: 772

Is it the data-confirm attribute you are looking for?

f.submit('Save Article'), data: {confirm: "Do more action?"}

Upvotes: 1

cih
cih

Reputation: 1980

Yes it can be done, CSS, Jquery (AJAX) probably how I would do it. You may want to break it down into stages.

  • Show a modal dialog on click of whatever link/button
  • AJAX to your rails controller and update the modal with your response data
  • Then repeat based on the users next action?

Check these links...

jQuery .html() to append response data. jQuery .ajax() to make request.

There are loads of modal/lightbox tutorials but pretty simple and better to learn if you have a go yourself. You can always post more specific questions when you have some code to show. Hope this helps.

Upvotes: 1

John Moses
John Moses

Reputation: 1283

Use a modal window. Twitter Bootstrap has a nice one. http://twitter.github.com/bootstrap/javascript.html#modals

Internet explorer has one built in. http://msdn.microsoft.com/en-us/library/ie/ms536759(v=vs.85).aspx

Upvotes: 1

Benson
Benson

Reputation: 22847

I think what you're looking for is something like the jQuery fancybox. You can throw a javascript submit hook on your form that pops up a fancybox and hits an XHR endpoint with something like $.get() before finally submitting the form.

Alternately, you could add a "published" field to the form in the database, go ahead and create the form on submit with published set to "false" and then have all kinds of interesting questions on the next page wherein you'd decide whether to publish or destroy the article.

Upvotes: 1

Related Questions