I was working on a project this week. There are several forms on one page, I want to submit any form without leaving the page. At first, this requirement really bothered me for a few minutes, after reading some documents from jQuery and Merb, it turns out pretty easy to implement:
1. View - file which have the forms you want to submit
In your form.html.erb file, you can create them like the normal forms.
2. Javascript(jQuery)
Here is the javascript to do the unobtrusive form submit.
3. Controller
In your controller's action, you have to specify provides :js
4. View - file which does the render
This is the good part I like Merb, you can mix Ruby code and javascript together to operate the DOM.
It is pretty easy and handy.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment