Steve
Steve

Reputation: 5952

ASP.net Ajax and JQuery - partial postback

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.

Upvotes: 5

Views: 5941

Answers (1)

joshb
joshb

Reputation: 5220

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
       });
   }
});

Upvotes: 11

Related Questions