Continuous jquery partial update

Rails 3.1.x - jquery

drag_drop.js
$(function() {
$( “[id^=moveable]” ).draggable();
$( “#droppable2” ).droppable({
drop: function( event, ui ) {
$( this )
.addClass( “ui-state-highlight” )
$.post( “groups/add_member/”, { “add”: ui.draggable.text() },
function(data) {
$(‘#member_management’).html(data) } );
}
});
});

The controller does “render :partial => ‘memberships’” and my
memberships.js.erb has
$(‘#memberships’).load(“<%= escape_javascript(render(:partial =>
“memberships”, :object => @group)) %>”);

Works - well, I still need a way to pass @group instance variable in the
‘post’ string back to controller but in the meantime, I am stuck in that
after the first drag/drop/update I can’t do more drag and drop
apparently because the drag_drop.js code needs to run again after the
partial refresh.

How do I get this to execute again or must I necessarily embed the
script in the memberships.js.erb ?


Craig W. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[email protected]
1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
www.ttiassessments.com

Need help communicating between generations at work to achieve your
desired success? Let us help!

On 13 Dec 2011, at 21:29, Craig W. [email protected] wrote:

Works - well, I still need a way to pass @group instance variable in the ‘post’
string back to controller but in the meantime, I am stuck in that after the first
drag/drop/update I can’t do more drag and drop apparently because the drag_drop.js
code needs to run again after the partial refresh.

How do I get this to execute again or must I necessarily embed the script in the
memberships.js.erb ?

Typically I’d use the callback that updates the dom to setup any stuff
like that. When you’re only adding event handlers there’s also the
.live stuff that you can use to bind event handlers for dom elements
that don’t exist yet

Fred