jQuery and Telerik RadControls

We ran into quite an odd issue today at work.  We’ve built this webpage that is all AJAX-iffied and such, and found out that any time we would select a drop down list, our help link buttons stopped working.

All the help link buttons are little jQuery elements that are extremely simple:

$('.showHelp').click(function (e) {
     e.preventDefault();
     ShowHelp();
}

We determined that every time we would cause a postback (albeit a partial one), we would lose the onClick event of the .showHelp classes … found out that neither the UpdatePanel nor Telerik’s RadPanels do this automatically.  I figured that something wasn’t initializing on the postback, so after searching for some time I came across the following:

http://encosia.com/document-ready-and-pageload-are-not-the-same/

We ended up with the following:

// Loads on Window Load
$(window).load(function () {
	pageLoad();
})

// Loads on Postback
function pageLoad()
{
	$('.showHelp').click(function (e) 
	{
		e.preventDefault();
		ShowHelp();
	}
}

Works perfectly now.

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: