Permalink
Browse files

ajax demos, more utility examples

  • Loading branch information...
stuarthalloway committed Aug 25, 2009
1 parent 8825578 commit 334076c2c4a4d1204f35af59fe00d3c43ad88e1a
@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
- protect_from_forgery # :secret => 'cb478af098cfa9f3152ab0a6f6c4dbad'
+ # protect_from_forgery # :secret => 'cb478af098cfa9f3152ab0a6f6c4dbad'
# See ActionController::Base for details
# Uncomment this to filter the contents of submitted sensitive data parameters
@@ -1,2 +1,6 @@
class DemosController < ApplicationController
+ def echo
+ @args = params.delete_if {|k,v| k == "action" || k == "controller" }
+ render :layout => false
+ end
end
@@ -0,0 +1,38 @@
+<form id="highlight" style="float:right">
+ <p>$("#
+ <input type="text" name="selector" id="selector"/>
+ ").load(
+ <input type="text" name="url" id="url"/>
+ ,
+ <input type="text" name="params" id="params"/>
+ )
+ <input type="button" name="load" value="load" id="load"/>
+ </p>
+ <pre><code id="load-code">
+
+ </code></pre>
+</form>
+
+
+<h1>Ajax Demo</h1>
+
+<p id="response">[Load responses here]</p>
+
+<script type="text/javascript">
+$(function() {
+ $.fn["evalCode"] = function() {
+ this.each(function() {
+ eval($(this).text());
+ });
+ }
+ $("#load").click(function() {
+ $("#load-code").text("$('#" +
+ $("#selector").val() +
+ "').load('" +
+ $("#url").val() +
+ "', " +
+ $("#params").val() +
+ ")").evalCode();
+ });
+});
+</script>
@@ -0,0 +1,2 @@
+<h2>Howdy</h2>
+<p>You said <%= @args.to_json %>.</p>
@@ -4,6 +4,7 @@
<li><%= link_to "selectors", :action => "selectors" %></li>
<li><%= link_to "events", :action => "events" %></li>
<li><%= link_to "effects", :action => "effects" %></li>
+ <li><%= link_to "ajax", :action => "ajax" %></li>
<li><%= link_to "sandbox", :action => "sandbox" %></li>
</ul>
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit 334076c

Please sign in to comment.