Jump to content

Paste Event - Get The "paste" Value.


kvnmck18

Recommended Posts

Any ideas on how to get the value of the paste event? Below is my code (so far). I'm sure there is a simple solution to pull the event's data. Right now all this does is just alert "paste" when text is pasted into a textarea ~ but I want it to alert the value of the paste.

$("textarea").bind('paste', function(e) {	 var text = e.event;	 alert(text);})

Link to comment
Share on other sites

I'm having issues with that - if it would a "standard" event like a click, it would be easy. But I can't get the log of "paste"Any idea on how?

Link to comment
Share on other sites

Here's my code with the log:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />	<title>Untitled</title>	<script type="text/javascript" src="jquery-1.2.6.js"></script>	<script type="text/javascript">		$(document).ready(function() {			$("textarea").bind('paste', function(e) {								Fnc(e);			})			function Fnc(e) {				var text = e.handler.prototype.value;				console.log(e);				alert(text);			}		});	</script></head><body>	<textarea cols="50" rows="10"></textarea></body></html>

But I can't find anywhere in the log that has the data that is "stored in the paste". Have you tried?

Link to comment
Share on other sites

No, I haven't tried, I haven't used jquery much at all actually. If the event object doesn't contain the data that was pasted then I don't know where to look for it. Check in the jquery documentation for the paste event to see what the event handler receives. There might be additional parameters other than the event object.

Link to comment
Share on other sites

jQuery docs are limited for paste event - that's why it's difficult. But, I know there has to be way to get that data.justsomeguy, you should add this to your list of languages. I think you would love it* - syntax is very very simple to use and it is extremely powerful and light. :)I'm going to continue to dig on this! Let me know if you think of anything else // I appreciate your thoughts[*Based off of your posts and your vast knowledge of other languages/scripts]

Link to comment
Share on other sites

  • 10 months later...

If you dindn't find answer yet here is some working code (except opera, FF < 2):

$(document).ready(function(){$("#my_input").bind('keyup paste', function(e){	var ob = $(this);	if (e.type == 'paste'){	setTimeout(function(){myFuncion(ob)}, 1);	} else myFuncion(ob);});});function myFuncion(ob) {alert(ob.val());}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...