Simple Cloning
$('#simple-clone').cloneya();
Nested Cloning
$('.nest-clone').cloneya();
Nested Cloning with preserveChildCount
$('.nest-clone-p').cloneya({
preserveChildCount: true
});
Max 3, Min 2
$('#limit-clone').cloneya({
maximum: 3,
minimum: 2
})
.on('maximum.cloneya', function (e, limit, toclone) {
var limitmsg = 'No more than ' + limit + ' clones for you!'
alert(limitmsg);
})
.on('minimum.cloneya', function (e, limit, toclone) {
var limitmsg = 'No less than ' + limit + ' clones for you!'
alert(limitmsg);
});
Animated with custom events
(Also see what happens to the id's)
$('#animate-clone').cloneya()
.on('before_clone.cloneya', function (event, toclone) {
// do something
})
.on('after_clone.cloneya', function (event, toclone, newclone) {
// do something
})
.on('before_append.cloneya', function (event, toclone, newclone) {
$(newclone).css('display', 'none');
$(toclone).fadeOut('fast', function () {
$(this).fadeIn('fast');
});
})
.on('after_append.cloneya', function (event, toclone, newclone) {
$(newclone).slideToggle();
console.log('finished cloning ' + toclone.attr('id') + ' to ' + newclone.attr('id'));
})
.off('remove.cloneya')
.on('remove.cloneya', function (event, clone) {
clone.css('background-color', 'red');
$(clone).slideToggle('slow', function () {
$(clone).remove();
});
})
.on('after_delete.cloneya', function () {
console.log('deleted');
});