views:

132

answers:

2

I have a ASP updatepanel, within that panel I have some controls which got jQuery effects connected to them.

The effects work perfect before posback, after postback the effects only work in IE not in FF. To get it working in IE I added the following to my MasterPage:

function pageLoad(sender, args) { // Initialize jQuery effects. }

With this code it works in IE but bot in FF, anyone got an answer to this one?

A: 

The pageLoad shortcut definitely does work the same way in Firefox as in IE. Double check that you don't have any JavaScript errors that are only throwing in Firefox.

Dave Ward
+2  A: 

You need to rebind your effects after the UpdatePanel finishes loading. You can achieve that by adding the following code:

<script type=”text/javascript”>

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(panelLoaded);

function panelLoaded(sender, args){

    // Rebind your elements/effects here.

}

</script>
a432511
The function he's using, pageLoad, is automatically called by the PageRequestManager after each partial postback (and when the page initially loads too).
Dave Ward
The key difference would be (and im not sure if this is true), that adding the function to the pageLoaded event would ensure that the content has fully loaded before trying to bind to the elements. I believe that the pageLoad function is called when the page begins to load.
a432511
pageLoad is a safe time to manipulate the updated DOM. The documentation insinuates that pageLoad comes significantly earlier, but they are comparable. This demo helps with that: http://www.asp.net/ajax/documentation/live/Samples/ClientEventExample1/cs/Default.aspx
Dave Ward