https://github.com/aquaflamingo/ajax-sjr-example
Server generated JavaScript Response example in Rails
https://github.com/aquaflamingo/ajax-sjr-example
on rails rails5 ruby
Last synced: 5 months ago
JSON representation
Server generated JavaScript Response example in Rails
- Host: GitHub
- URL: https://github.com/aquaflamingo/ajax-sjr-example
- Owner: aquaflamingo
- Created: 2020-07-07T13:44:40.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2022-04-27T16:13:49.000Z (about 4 years ago)
- Last Synced: 2024-09-27T15:20:12.886Z (over 1 year ago)
- Topics: on, rails, rails5, ruby
- Language: Ruby
- Homepage:
- Size: 1.05 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AJAX Server Generated JS Rails Example
This repository contains sample code for a Rails Server Generated JavaScript Response (SJR).
## Example
The `index` action contains a `_form` partial for submitting new notes remotely through an AJAX request. When the XHR request is submitted async the `NotesController` `create` action renders the `create.js.erb` template. This template searches the current HTML for an `id=notes_list` element, and appends to its HTML the newly saved note. Because this JavaScript is generated from the server and sent to the client, the client does not need to rerender the page or redirect it only needs to render the new note in its existing HTML.
## Licence
MIT