kvnmck18 Posted February 21, 2009 Share Posted February 21, 2009 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 More sharing options...
justsomeguy Posted February 23, 2009 Share Posted February 23, 2009 Examine e to see what it offers. I would use something like Firebug to do that. Link to comment Share on other sites More sharing options...
kvnmck18 Posted March 1, 2009 Author Share Posted March 1, 2009 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 More sharing options...
justsomeguy Posted March 2, 2009 Share Posted March 2, 2009 I would just write console.log(e), it will show the object in the Firebug console and you can see what properties and methods it has. Link to comment Share on other sites More sharing options...
kvnmck18 Posted March 3, 2009 Author Share Posted March 3, 2009 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 More sharing options...
justsomeguy Posted March 4, 2009 Share Posted March 4, 2009 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 More sharing options...
kvnmck18 Posted March 5, 2009 Author Share Posted March 5, 2009 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 More sharing options...
Guest Karol Posted January 26, 2010 Share Posted January 26, 2010 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 More sharing options...
Synook Posted January 26, 2010 Share Posted January 26, 2010 jQuery isn't a new language, it is just a framework. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.