I've made the functionality of moving an element between lists with
jQuery like this:
jQuery(document).ready(function() {
jQuery("#manager").sortable({
connectWith: ['#volunteer', '#manager'],
receive: function(event, ui) {
}
});
jQuery("#volunteer").sortable({
connectWith: ['#manager', '#available']
});
jQuery("#available").sortable({
connectWith: ['#volunteer', '#manager']
});
});
the receive function should hold the ajax call to the database, but
i'm not really sure what to put there. is there a pure JS-way to
update the transition..?
Bryan
I my case i have 3 transistions with these generated routes PUT:
/event_attendees/:id/available
/event_attendees/:id/volunteer
/event_attendees/:id/manage
The list item itself that gets moved (and triggers the receive
function) hasn't got any id, so i'm looking for at nice way of
implementing that, so its easy for the js to pull it out (sorry for
the noob approach, but i haven't really worked with js before).
On 5 Feb., 15:04, Bryan Larsen <bryan.lar...@gmail.com> wrote:
> http://cookbook.hobocentral.net/manual/ajax#submitting_an_ajax_form_v...
> I can see that the Hobo.ajaxRequest should have a URL to invoke
> (obviously :))..
>
> I my case i have 3 transistions with these generated routes PUT:
> /event_attendees/:id/available
> /event_attendees/:id/volunteer
> /event_attendees/:id/manage
>
> The list item itself that gets moved (and triggers the receive
> function) hasn't got any id, so i'm looking for at nice way of
> implementing that, so its easy for the js to pull it out (sorry for
> the noob approach, but i haven't really worked with js before).
>
All you'll need is some way to get the corresponding ID out of the
draggable objects - maybe a hidden field? I've also (ab)used the rel=
attribute to handle this - you can grab it with
jQuery(object).attr('rel').
--Matt Jones
I've added the id to the li-tag "<li id="24">..</li>", and use this
receive function:
receive: function(event, ui) {
Hobo.ajaxRequest('/event_attendees/'+ui.item.attr('id')+'/manage',
['#list-available', '#list-volunteers', '#list-managers'], { method:
"PUT" });
}
Also had to clear a bunch of other errors in my various files before
it worked properly..
AJAX is so sweet when it works..!
THX GUYS..!
<div id="attendee-#{this_field}">
var id=parseInt(object.id.replace("attendee-", ""));
Bryan