Side navigation
#5249 closed bug (worksforme)
Opened September 15, 2009 10:28PM UTC
Closed June 13, 2010 05:43PM UTC
Last modified March 10, 2012 07:55AM UTC
clipboardData (and other new properties) not copied to new event object
| Reported by: | paulschreiber | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | event | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
When jQuery creates a new event object, the clipboardData property is not copied to the new object.
This means that when you try and bind a paste event, it won't be very useful, as event.clipboardData is empty, so you can't process the contents of the clipboard.
STEPS TO REPRODUCE
Here's a small example:
$(document).ready(function () {
$(".my-text-field").each(function(){
$(this).bind("paste", foo);
this.addEventListener("paste", bar, false);
});
});
function foo(e) {
alert("foo:" + e.clipboardData);
alert("foo: clipboard text is:" + e.clipboardData.getData("text/plain"));
}
function bar(e) {
alert("bar:" + e.clipboardData.getData("text/plain"));
alert("bar: clipboard text is:" + e.clipboardData.getData("text/plain"));
}
Here's a working example of the reduction:
http://pastie.org/pastes/618082
WORKAROUND
Insert this line before running any of your code:
jQuery.event.props.push('clipboardData');
Attachments (0)
Change History (1)
Changed June 13, 2010 05:43PM UTC by comment:1
| component: | unfiled → event |
|---|---|
| resolution: | → worksforme |
| status: | new → closed |
There is a high cost to copying and normalizing event properties, so only a small subset of properties are processed.
The event.originalEvent object has the complete original event object, and you should be able to get the data from there.