pi.util.AddEvent
Summary
Allows the registration of event listeners on the event target.
Syntax
pi.util.AddEvent(target,type,listener,useCapture);
Usage Example
>>> pi.util.AddEvent(window,"mousedown",function(){ alert("hello!"); });
Examples
Example #1: Print a random message when user click a button.
Source files of the above example:
../../examples/randomMessage.html
<button id="mybutton">Print A Message</button>
<div id="messageContainer">
</div>
../../examples/randomMessage.js
pi.util.AddEvent(pi.get("mybutton"),"click",function(){
pi.get("messageContainer").innerHTML=messages[ pi.util.Number.random(0,messages.length-1) ];
});
var messages = ["Something's going on.","It has to do with that number.","There's an answer in that number.","If the number's there I'll find it!","Number?"];