Welcome Guest, Not a member yet? Register   Sign In
document.getElementById
#2

[eluser]slowgary[/eluser]
Try posting a little more info. What is it you're trying to do? I'm assuming you don't plan on hardcoding the id. You could bind an event on each of the list items, e.g.
Code:
foreach()
   <li class='sort_item'><php echo $box->boxText; ?&gt;</li>
endforeach;

&lt;script type='text/javascript'&gt;
var current_item_id = NULL;
$('.sort_item').each(function(){
     $(this).bind('mousedown', function(){
          current_item_id = $(this).attr('id');
     });

     $(this).bind('mouseup', function(){
          current_item_id = NULL;
     });
});

$("#listA, #listB, #listC").sortable({
            connectWith: ['.connect'],
            over: function(event, ui) {
                    var order = 'listname=' + $(this).attr('id') + '&id;=' + current_item_id;
                    $.post("home/jupdate", order, function(theResponse){
                        $("#contentRight").html(theResponse);
                    });                                                          
            }
});

This might work, but there's probably a better way. Doesn't the sortable method provide you with a way to access the active element and it's attributes? When you specify the 'over:' handler or callback, you have access to the event object, so you should be able to do something like:
Code:
$("#listA, #listB, #listC").sortable({
            connectWith: ['.connect'],
            over: function(event, ui) {
                    var order = 'listname=' + $(this).attr('id') + '&id;=' + $(event.srcElement).attr('id');
                    $.post("home/jupdate", order, function(theResponse){
                        $("#contentRight").html(theResponse);
                    });
            }
});

Good luck with that. I would do a bunch more investigating if I were you. Usually when you're using a sortable list, you need to send the elements or the entire list to a server side script in order for the sortable list to actually be useful. For this reason, what you're trying to do should be very easy and commonplace. Maybe you can find better help on #jquery irc channel. If you're not familiar with irc, try searching google for a web based client called mibbit, choose the freenode network, and type in '#jquery' for the channel.


Messages In This Thread
document.getElementById - by El Forum - 05-25-2009, 04:51 PM
document.getElementById - by El Forum - 05-25-2009, 11:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB