views:

952

answers:

1

A radiobutton list and a repeater are in an updatepanel. The repeater is using a jQuery tools plugin - scrollable.

The scrollable plugin works after the initial page load. It does not after I click on a radio button.

I put in an input button to run the script below after a partial postback and the scrollable functionality works after I click it, so I'm guessing after the radio button click/partial postback, the javascript below that is needed by scrollable isn't being run.

The scrollable plugin requires this:

<script type="text/javascript">
    $(function() {
        $("div.scrollable").scrollable({
            size: 3
        });
    }); 
</script>

How do I run this after the radiobutton click? Or is there an alternate way to get this script to run after a partial postback? I don't want to do a full postback to remedy the problem.

Thanks in advance.

+4  A: 

Scrollable is not working after the partial postback because that portion of the page is re-rendered but the page is not loaded again (your javascript is not run). You can register a function to run when the partial post back completes and call scrollable from there to ensure it continues to work after the partial postback.

$(function() {
   Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

   function EndRequestHandler(sender, args) {
      $("div.scrollable").scrollable({
         size: 3
       });
   }
});
joshb
Thanks! That did the trick. After I posted, I thought it had something to do with the MS Ajax client library. I'm going to have give it a good going over.
Steve
Thanks! I didn't know this :) I used to re-register the script with a ScriptManager on postback
Andrea
Perhaps someone might find these useful. MS Ajax client javascript library cheatsheets:http://aspnetresources.com/blog/ms_ajax_cheat_sheets_batch1.aspx
Steve