Skip to content

Commit

Permalink
ajax demos, more utility examples
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthalloway committed Aug 25, 2009
1 parent 8825578 commit 334076c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/application.rb
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/demos_controller.rb
@@ -1,2 +1,6 @@
class DemosController < ApplicationController
def echo
@args = params.delete_if {|k,v| k == "action" || k == "controller" }
render :layout => false
end
end
38 changes: 38 additions & 0 deletions app/views/demos/ajax.html.erb
@@ -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>
2 changes: 2 additions & 0 deletions app/views/demos/echo.html.erb
@@ -0,0 +1,2 @@
<h2>Howdy</h2>
<p>You said <%= @args.to_json %>.</p>
1 change: 1 addition & 0 deletions app/views/demos/index.html.erb
Expand Up @@ -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>

Binary file modified doc/jQuery.key
Binary file not shown.
Binary file added jQuery-1up.pdf
Binary file not shown.
Binary file added jQuery-4up.pdf
Binary file not shown.

0 comments on commit 334076c

Please sign in to comment.