View on GitHub

jQuery Cloneya Build Status

Demo and Examples

Home

Download this project as a .zip file Download this project as a tar.gz file

Simple Cloning

$('#simple-clone').cloneya();

clone delete

Nested Cloning

$('.nest-clone').cloneya();
Personal Details

Contact Information

Additional Phone

clone delete
clone delete
clone delete

Nested Cloning with preserveChildCount

$('.nest-clone-p').cloneya({
    preserveChildCount: true
});
Personal Details

Contact Information

Additional Phone

clone delete
clone delete
clone delete

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);
        });

clone delete

clone delete

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');
        });

clone delete