views:

30

answers:

1

I have got an issue after updation in UpdatePanel. The issue is the jquery events are not working/firing after the updation in UpdatePanel. At first time, the jquery events work, but not after the updation in UpdatePanel. If I remove the UpdatePanel, the problem is solved. But I have to use the UpdatePanel.

Can you give me a solution for this ?

+1  A: 

One of the possible reasons for this is that the UpdatePanel replaces elements in the DOM that had jquery events attached to them which of course nullifies those events. One possible solution would be to use the .live() function to register events but it works only with some events.

If you can't use the live function you will need to reattach those events once the UpdatePanel has finished replacing DOM elements:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(sender, args) {
    // TODO: reattach your jquery event handlers
});
Darin Dimitrov
for using .live(), can we use under normal jquery ? Or should we have to download any plugin/javascript file ?
Sreejesh Kumar
`.live()` function is part of jquery (see the link in my post) so you can use it directly.
Darin Dimitrov
ok...let me try....should we use .live() on each time the UpdatePanle executes or at page load itself ?
Sreejesh Kumar
Only at page load.
Darin Dimitrov
Can you just give me sample code of registering livequery plugin for a method ? Also the page load. for example I have two methods "draggable" and "droppable".This is waht I had written : $(document).ready(function() { if (jQuery.livequery) jQuery.livequery.registerPlugin("draggable", "droppable"); InitializePage(); }); function InitializePage() { $(".draggable").live("draggable",{ helper: 'clone', scroll: false }); BindDropEvent(); }
Sreejesh Kumar
function BindDropEvent() { $(".droppable").live("droppable",{ drop: function(ev, ui) { } }); }
Sreejesh Kumar
.live() works only with basic events. I highly doubt that it works with `droppable`. Read the documentation of supported events.
Darin Dimitrov
Hey Darin. The problem is solved. I had to correct in the jquery javascript file. Now its working in UpdatePanel. Thanks for your help too.
Sreejesh Kumar