aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Steele <danielsteele@hotmail.co.uk>2015-06-09 16:56:59 +0100
committerDaniel Steele <danielsteele@hotmail.co.uk>2015-06-09 16:56:59 +0100
commit0cab6c948482d73a200315f7930349c4eaa05176 (patch)
treee13d00f5a52199cc1952777565ae1e3af5ede9c1
parentc0c3ef3a298f0f63e4dc32699c2e5f0e2cab3faf (diff)
downloadrails-0cab6c948482d73a200315f7930349c4eaa05176.tar.gz
rails-0cab6c948482d73a200315f7930349c4eaa05176.tar.bz2
rails-0cab6c948482d73a200315f7930349c4eaa05176.zip
Removed AJAX example with poor convention adherence
The removed section promotes putting JS code directly inside the controller, this is not in line with convention.
-rw-r--r--guides/source/working_with_javascript_in_rails.md24
1 files changed, 0 insertions, 24 deletions
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index e3856a285a..19128f288e 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -191,30 +191,6 @@ $(document).ready ->
Obviously, you'll want to be a bit more sophisticated than that, but it's a
start. You can see more about the events [in the jquery-ujs wiki](https://github.com/rails/jquery-ujs/wiki/ajax).
-Another possibility is returning javascript directly from the server side on
-remote calls:
-
-```ruby
-# articles_controller
-def create
- respond_to do |format|
- if @article.save
- format.html { ... }
- format.js do
- render js: <<-endjs
- alert('Article saved successfully!');
- window.location = '#{article_path(@article)}';
- endjs
- end
- else
- format.html { ... }
- format.js do
- render js: "alert('There are empty fields in the form!');"
- end
- end
- end
-end
-```
NOTE: If javascript is disabled in the user browser, `format.html { ... }`
block should be executed as fallback.