1

I have a problem and possible solution but I'd appreciate a little help with using it.

I have a ASP.NET Timer and when it Ticks I call asynchronously web service method that returns me a photo. I have a image in Update Panel and update it src when I get a photo. I'm using a jQuery lightBox plugin to preview a image. The mechanism works but on a partial postbacks image loses attatched plugin. So I need re-attaching functionality to elements within UpdatePanels.

Possible solution is using ASP.NET AJAX’s pageLoad() to re-attach (http://encosia.com/simplify-aspnet-ajax-client-side-page-initialization/)

I attach plugin with:

<script type="text/javascript">
$(function () {
$('#gallery a').lightBox({ fixedNavigation: true });
});
</script>

As it is said pageLoad() should solve the problem, but how to modify this js to use pageLoad ?

1)How sholud look my js script ? I'm a begginer with js so please help me.

2)Moreover, should I attach sth to my project to use pageLoad() ?

Thanks in advance for Your help.

JohnS
  • 11
  • 1

1 Answers1

0

Since you're already using jQuery, you may want to use its live() or delegate() functions which allow you to bind event handlers to current and future elements that match a selector.

dbb
  • 1,100
  • 6
  • 12
  • Thanks for answer. I will try it if pageLoad() doesn't help. But any ideas how to modify my js call with pageLoad() ? – JohnS Jul 23 '11 at 15:17
  • Well according to the page you linked to simply declaring a javascript function named `pageLoad()` should suffice. Add whatever you need to do to that function. – dbb Jul 24 '11 at 12:37