Revision: 32587
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 29, 2010 17:34 by Meander365
Initial Code
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="../assets/js/jquery.js"></script> <script type="text/javascript"> $(function () { $('#animate').bind('click', function(e){ // Do something with e.name, e.surname, etc. var newHtml = e.type || []; newHtml = e.from || $(this).attr("id"); newHtml += e.name || []; newHtml += e.surname || []; newHtml += e.age || []; newHtml += e.gender || []; $(".box").empty().append(newHtml); }); $('#animate-fake').mouseover(function() { $("#animate").trigger({ type:'click', //the bound event of the handler from:$(this).attr("id"), name:'John', surname:'Doe', age: 28, gender:'male' }); }); }); </script> </head> <body> <style type="text/css"> .box {width:100%;min-height:30px;background:#efefef;border:1px solid #ccc;} </style> <a href="#" id="animate">Show me the object</a><br /><br /> <div class="box"></div><br /><br /> <a href="#" id="animate-fake">Hover Over Me</a> </body> </html>
Initial URL
Initial Description
I can see this being useful for when you want to pass a lot of associated data to an event handler from elements and their chosen trigger action.
Initial Title
Jquery Passing Dynamic Data to Event Handlers
Initial Tags
javascript, data, jquery
Initial Language
jQuery