简体   繁体   中英

Updating part of a web page on Rails

I have a Rails controller with a form, and I want that when I post this form, a table on this page is updated via AJAX. I know a way, using partials to achieve this, but is that any way to do this without partials? And without putting code for my view inside my controller too.

Thanks

You can make a .js.erb file as the view, and from the form call the action from link_to_remote. That will translate into an ajax call to the action, that will then execute the js from the view. Inside that js.erb file you can do whatever you like. Although it will be hard to render part of the table server side if the code isn't broken out into a partial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM