Search This Blog

Tuesday, August 24, 2010

add custom Events using jQuery

Hello friends,
I have faced a problem of adding a event handler to a control which is not present in my case i need a event which should be triggered after resizing a control for example my div is of size "25px" and resizing the div to "50px" after resizing to "50px" the event should be triggered . I found a solution in jQuery which i have shared below

there is a function called "trigger"(http://api.jquery.com/trigger/) which is used to trigger a event or action 

example 
$(this).trigger("onresize",newsize); //add this statement to your function which resizes your control
$('#mycontrol').bind('onresize', function(e,newsize) {
  alert('your control has been resized to :'+newsize)
});// this is the call on your page instead of function you can also use function name first param will be object "e" others from the trigger function(above) parameters 

No comments:

Post a Comment