Browse files

working on events

  • Loading branch information...
1 parent 54c123c commit 85259aadec68055aa02b4a7990cfd6b338e5bbcd @stuarthalloway stuarthalloway committed Jun 14, 2009
View
44 app/views/demos/events.html.erb
@@ -0,0 +1,44 @@
+<form id="events" style="float:right">
+ <p>
+ <label for="event">Event:</label><br/>
+ <input type="text" name="event" id ="event"/>
+ </p>
+ <p>
+ <label for="selector">Selector:</label><br/>
+ <input type="text" name="selector" id ="selector"/>
+ </p>
+ <p>
+ <input type="submit" value="Bind it!"/>
+ </p>
+</form>
+
+<h1>Events Demo</h1>
+
+<div id="section-1">
+ <p id="p1" class="vivid leader">Paragraph 1</p>
+ <p id="p2">Paragraph 2</p>
+ <p id="p3" class="honorificabilitudinitatibus">Paragraph 3 has a <span>nested span</span></p>
+ <p id="p4" class="vivid">Paragraph 4</p>
+ <p id="p5">Paragraph 5 has a <span>doubly <span> nested span</span> </span></p>
+ <div>This is not a paragraph</div>
+</div>
+
+<br/>
+
+<div id="log">
+
+</div>
+
+<script type="text/javascript">
+ $(function() {
+ $("#events").submit(function() {
+ var count = 0;
+ var eventName = $("#event").val()
+ $($("#selector").val()).bind(eventName, function() {
+ count = count + 1;
+ $("#log").prepend("Saw event " + eventName + " " + count + " ");
+ });
+ return false;
+ });
+ });
+</script>
View
1 app/views/demos/index.html.erb
@@ -2,4 +2,5 @@
<ul>
<li><%= link_to "selectors", :action => "selectors" %></li>
+ <li><%= link_to "events", :action => "events" %></li>
</ul>
View
21 app/views/demos/selectors.html.erb
@@ -1,19 +1,20 @@
+<form id="highlight" style="float:right">
+ <label for="selector">Selector:</label>
+ <input type="text" name="selector" id ="selector"/>
+ <input type="submit" value="Highlight it!"/>
+</form>
+
<h1>Selectors Demo</h1>
<div id="section-1">
- <p class="vivid leader">Paragraph 1</p>
- <p>Paragraph 2</p>
- <p>Paragraph 3 has a <span>nested span</span></p>
- <p class="vivid">Paragraph 4</p>
- <p>Paragraph 5</p>
+ <p id="p1" class="vivid leader">Paragraph 1</p>
+ <p id="p2">Paragraph 2</p>
+ <p id="p3" class="honorificabilitudinitatibus">Paragraph 3 has a <span>nested span</span></p>
+ <p id="p4" class="vivid">Paragraph 4</p>
+ <p id="p5">Paragraph 5 has a <span>doubly <span> nested span</span> </span></p>
<div>This is not a paragraph</div>
</div>
-<form id="highlight">
- <label for="selector">Selector:</label>
- <input type="text" name="selector" id ="selector"/>
- <input type="submit" value="Highlight it!"/>
-</form>
<script type="text/javascript">
$(function() {
View
BIN doc/jQuery.key
Binary file not shown.

0 comments on commit 85259aa

Please sign in to comment.