Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
ba7195e3
Commit
ba7195e3
authored
Feb 27, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it so that you can pass in event data to .click(), et. al. Fixes #6187.
parent
9e06903a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
event.js
src/event.js
+4
-2
event.js
test/unit/event.js
+11
-0
No files found.
src/event.js
View file @
ba7195e3
...
@@ -1071,8 +1071,10 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
...
@@ -1071,8 +1071,10 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
"change select submit keydown keypress keyup error").split(" "), function( i, name ) {
"change select submit keydown keypress keyup error").split(" "), function( i, name ) {
// Handle event binding
// Handle event binding
jQuery.fn[ name ] = function( fn ) {
jQuery.fn[ name ] = function( data, fn ) {
return fn ? this.bind( name, fn ) : this.trigger( name );
return data || fn ?
this.bind( name, fn ? data : null, fn || data ) :
this.trigger( name );
};
};
if ( jQuery.attrFn ) {
if ( jQuery.attrFn ) {
...
...
test/unit/event.js
View file @
ba7195e3
...
@@ -11,6 +11,17 @@ test("bind(), with data", function() {
...
@@ -11,6 +11,17 @@ test("bind(), with data", function() {
ok
(
!
jQuery
.
data
(
jQuery
(
"#firstp"
)[
0
],
"events"
),
"Event handler unbound when using data."
);
ok
(
!
jQuery
.
data
(
jQuery
(
"#firstp"
)[
0
],
"events"
),
"Event handler unbound when using data."
);
});
});
test
(
"click(), with data"
,
function
()
{
expect
(
3
);
var
handler
=
function
(
event
)
{
ok
(
event
.
data
,
"bind() with data, check passed data exists"
);
equals
(
event
.
data
.
foo
,
"bar"
,
"bind() with data, Check value of passed data"
);
};
jQuery
(
"#firstp"
).
click
({
foo
:
"bar"
},
handler
).
click
().
unbind
(
"click"
,
handler
);
ok
(
!
jQuery
.
data
(
jQuery
(
"#firstp"
)[
0
],
"events"
),
"Event handler unbound when using data."
);
});
test
(
"bind(), with data, trigger with data"
,
function
()
{
test
(
"bind(), with data, trigger with data"
,
function
()
{
expect
(
4
);
expect
(
4
);
var
handler
=
function
(
event
,
data
)
{
var
handler
=
function
(
event
,
data
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment