I have two lists working as a connected sortable. What I want to do is
want to get the element that we are sorting, grab its class and id
value, parse out a component of this ID (which has been written
dynamically), write a new class and id to the element based on this
information, then submit the new sorted list (sortable2) to a database
using ajax.
With the code below (written for clarity), I see two alerts, both
providing me with the same value. So, it appears that the sorted
element is copied and on update, two elements exist and implicity, the
update loops through both.
<script type="text/javascript">
$(function()
{
$("##sortable1, ##sortable2")
.sortable
({
connectWith:
'.connectedSortable',
opacity:60,
update: function(event,ui)
{
temp = ui.item.attr("class");
alert('value is '+temp);
}
})
.disableSelection();
});
</script>
If I replace the update code with something like:
temp = ui.item.attr("class");
if (temp.indexOf("default") == -1)
{
ui.item.attr("class","ui-state-default");
}
else
{
ui.item.attr("class","ui-state-highlight");
}
then the class is first changed, then changed back again. How do I
gain better control of this? How do I access just one of the elements?
Can someone explain what is going on?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---