I have binded jquery events set for mouseenter mouseleave, as well as jquery draggable. The divs are placed in an update panel and when a button is clicked information is sent to the database and the update panel is updated. However when the panel is updated the jquery events no longer work. Any idea as to why this would be the case?
A:
Use live.
$("div").live("mouseenter", function(){
// do something
});
Daniel Moura
2009-07-30 15:05:09
from the jquery docs for "live":Currently not supported: blur, focus, mouseenter, mouseleave, change, submit
John Boker
2009-07-30 15:09:59
A:
try using
function pageLoad(sender, args)
{
// JQuery code goes here
}
instead of
$(document).ready(function() {
// JQuery code goes here
});
This will work when a button that is within an update panel is clicked; it goes to the server and will re-add the jquery when it comes back. However, this does not work with Asynchronous postbacks caused by a control such as the eo:AJAXUploader but combining this with Bryans version you can handle Asynchronous postbacks as well
jmein
2009-07-30 15:10:21
+4
A:
You can add an Asynchronous trigger to your page to call a JavaScript/jQuery function after any async call.
Place this code in your Page_Load() of your aspx code behind:
//This script handles ajax postbacks, by registering the js to run at the end of *AJAX* requests
Page.ClientScript.RegisterStartupScript(typeof(Page), "ajaxTrigger", "Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);", true);
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "EndRequest", "function EndRequestHandler(sender, args){AsyncDone();}", true);
This code snippet will specifically call the JavaScript/jQuery function AsyncDone();
Bryan Denny
2009-07-30 15:11:10
Did you try putting an alert to see if it is being called?You'll have to re-hook up your jquery events after every async page load inside of the AsyncDone() function.
Bryan Denny
2009-07-30 20:31:45