Created
February 25, 2011 07:58
-
-
Save michaeltwofish/843506 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Handle attaching children | |
$('#unattached_children a.add').click(function() { | |
var icons = $(this).parent(); | |
var child_type = // work out what the name of the child is | |
// Update label text | |
$('#attached_children>label').html('Attached '+child_type); | |
// Move the item to the attached items list | |
$('#AttachedItems .list').append($(this).closest('.item')); | |
$('#attached_children .list .item:last-child').append('<input name="'+child_type+'[]" type="hidden" value="'+$('#attached_children .list .item:last-child').attr('id')+'" />'); | |
// Fix the icons | |
$(this).parent().empty(); | |
icons.append('<a href="#" class="delete">Delete</a>').click(function() { | |
$(this).closest('.item').remove(); | |
return false; | |
}); | |
icons.append('<a href="#" class="move">Move</a>'); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment