Skip to content

Commit 8953884

Browse files
committed
Merge pull request jquery#127 from bentonam/events-example-conversion
updated formatting
2 parents f989df7 + 2cead80 commit 8953884

10 files changed

+457
-458
lines changed

page/events/event-delegation.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,19 @@ method is available, and is the preferred method.
2626
</div>
2727

2828
```
29-
//Event delegation using `$.fn.delegate`
30-
31-
$('#myUnorderedList').delegate('li', 'click', function(e) {
32-
var $myListItem = $(this);
33-
// ...
34-
});
29+
// Event delegation using `$.fn.delegate`
30+
$('#myUnorderedList').delegate('li', 'click', function(e) {
31+
var $myListItem = $(this);
32+
// ...
33+
});
3534
```
3635

3736
```
38-
//Event delegation using `$.fn.live`
39-
$('#myUnorderedList li').live('click', function(e) {
40-
var $myListItem = $(this);
41-
// ...
42-
});
37+
// Event delegation using `$.fn.live`
38+
$('#myUnorderedList li').live('click', function(e) {
39+
var $myListItem = $(this);
40+
// ...
41+
});
4342
```
4443

4544
### Unbinding Delegated Events
@@ -49,7 +48,7 @@ use `$.fn.undelegate` for events connected with `$.fn.delegate`, and `$.fn.die`
4948
for events connected with `$.fn.live`. As with bind, you can optionally pass
5049
in the name of the bound function.
5150
```
52-
//Unbinding delegated events
53-
$('#myUnorderedList').undelegate('li', 'click');
54-
$('#myUnorderedList li').die('click');
51+
// Unbinding delegated events
52+
$('#myUnorderedList').undelegate('li', 'click');
53+
$('#myUnorderedList li').die('click');
5554
```

page/events/event-extensions.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ When defined, these string properties specify that a special event should be han
9494

9595
The behavior of these properties is easiest to see with an example. Assume a special event defined as follows:
9696

97-
```jQuery.event.special.pushy = {
97+
```
98+
jQuery.event.special.pushy = {
9899
bindType: "click",
99100
delegateType: "click"
100101
};
@@ -112,10 +113,10 @@ So given the special event above, this code shows that a pushy isn't removed by
112113
```
113114
var $p = $("p");
114115
$p.on("click", function( e ) {
115-
$("body").append("I am a " + e.type + "!"));
116+
$("body").append("I am a " + e.type + "!"));
116117
});
117118
$p.on("pushy", function( e ) {
118-
$("body").append("I am pushy but still a " + e.type + "!");
119+
$("body").append("I am pushy but still a " + e.type + "!");
119120
});
120121
$p.trigger("click"); // triggers both handlers
121122
$p.off("click");

page/events/event-helpers.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Prior to jQuery 1.4, the `$.fn.hover` method required two functions.
1616
</div>
1717

1818
```
19-
//The hover helper function
20-
$('#menu li').hover(function() {
21-
$(this).toggleClass('hover');
22-
});
19+
// The hover helper function
20+
$('#menu li').hover(function() {
21+
$(this).toggleClass('hover');
22+
});
2323
```
2424

2525
### `$.fn.toggle`
@@ -31,7 +31,7 @@ however, it will accept an unlimited number of functions. Be careful, though:
3131
providing a long list of functions can be difficult to debug.
3232

3333
```
34-
//The toggle helper function
34+
// The toggle helper function
3535
$('p.expander').toggle(
3636
function() {
3737
$(this).prev().addClass('open');

page/events/events-to-elements.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ when you are working with custom events, or when you want to pass an object of
1111
multiple events and handlers.
1212

1313
```
14-
//Event binding using a convenience method
14+
// Event binding using a convenience method
1515
$('p').click(function() {
1616
console.log('click');
1717
});
1818
```
1919

2020
```
21-
//Event biding using the `$.fn.bind` method
21+
// Event biding using the `$.fn.bind` method
2222
$('p').bind('click', function() {
2323
console.log('click');
2424
});
2525
```
2626

2727
```
28-
//Event binding using the `$.fn.bind` method with data
28+
// Event binding using the `$.fn.bind` method with data
2929
$('input').bind(
3030
'click change', // bind to multiple events
3131
{ foo : 'bar' }, // pass in data
@@ -43,7 +43,7 @@ want no handler to run, or you may want a different handler to run. jQuery
4343
provides the `$.fn.one` method for this purpose.
4444

4545
```
46-
//Switching handlers using the `$.fn.one` method
46+
// Switching handlers using the `$.fn.one` method
4747
$('p').one('click', function() {
4848
console.log('You just clicked this for the first time!');
4949
$(this).click(function() { console.log('You have clicked this before!'); });
@@ -61,12 +61,12 @@ you can isolate the unbinding to that named function by passing it as the
6161
second argument.
6262

6363
```
64-
//Unbinding all click handlers on a selection
64+
// Unbinding all click handlers on a selection
6565
$('p').unbind('click');
6666
```
6767

6868
```
69-
//Unbinding a particular click handler, using a reference to the function
69+
// Unbinding a particular click handler, using a reference to the function
7070
var foo = function() { console.log('foo'); };
7171
var bar = function() { console.log('bar'); };
7272
@@ -81,7 +81,7 @@ useful to namespace your events so you don't unintentionally disconnect events
8181
that you didn't or couldn't know about.
8282

8383
```
84-
//Namespacing events
84+
// Namespacing events
8585
$('p').bind('click.myNamespace', function() { /* ... */ });
8686
$('p').unbind('click.myNamespace');
8787
$('p').unbind('.myNamespace'); // unbind all events in the namespace
@@ -95,7 +95,7 @@ an object into `$.fn.bind` with one or more key/value pairs, with the key being
9595
the event name and the value being the function to handle the event.
9696

9797
```
98-
//Binding Multiple Events
98+
// Binding Multiple Events
9999
$('p').bind({
100100
'click': function() { console.log('clicked!'); },
101101
'mouseover': function() { console.log('hovered!'); }

page/events/inside-event-handling-function.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ simply do $(this), often following this idiom:
4646
```
4747

4848
```
49-
//Preventing a link from being followed
50-
$('a').click(function(e) {
51-
var $this = $(this);
52-
if ($this.attr('href').match('evil')) {
53-
e.preventDefault();
54-
$this.addClass('evil');
55-
}
56-
});
49+
// Preventing a link from being followed
50+
$('a').click(function(e) {
51+
var $this = $(this);
52+
if ($this.attr('href').match('evil')) {
53+
e.preventDefault();
54+
$this.addClass('evil');
55+
}
56+
});
5757
```

0 commit comments

Comments
 (0)