Yapapaya / jquery-cloneya

A jquery plugin to clone DOM elements
MIT License
76 stars 28 forks source link

Woking with other plugin #17

Closed tranlamnhatnam closed 9 years ago

tranlamnhatnam commented 9 years ago

I use Cloneya with Bootstrap-datetime-picker but when clone new row datetime-picker work with only one input of row has been clone.

This is code in jsbin

untitled

tranlamnhatnam commented 9 years ago

Resolved with jquery ui datepicker

razuro commented 9 years ago

Did you solve that by re-initializing datepicker after creating clone?

tugich commented 9 years ago

I have the same issue, and tried to re-initializing the datepicker, but its not working:

            .on('before_clone.cloneya', function(event, toClone)
            {
                toClone.find('select, .autocomplete').select2('destroy');

                toClone.find('.date').datepicker('remove');
            })
            .on('after_append.cloneya', function(event, toClone, newClone)
            {
                Helper.Select2( toClone.find('select') );

                Helper.Datepicker( toClone.find('.date') );

                Helper.Select2( newClone.find('select') );

                Helper.Datepicker( newClone.find('.date') );
            });

I am using the bootstrap-datepicker: https://bootstrap-datepicker.readthedocs.org/en/latest/

Found a solution:

            .on('before_clone.cloneya', function(event, toClone)
            {
                toClone.find('select, .autocomplete').each(function()
                {
                    $(this).select2('destroy');
                });

                toClone.find('.date').each(function()
                {
                    $(this).datepicker('remove');
                });
            })
florentsorel commented 9 years ago

Someone has a solution with chosen plugin ?

gchokeen commented 9 years ago

I am sure it will work if you properly reinit the your external plugin on before_clone.cloneya, If you create the jsfiddle, then it will be easy to help you!

florentsorel commented 9 years ago

Found it ;)

.on('before_clone.cloneya', function(event, toClone)
{
    toClone.find('select').each(function()
    {
        $(this).chosen('destroy');
    });
})
.on('after_clone.cloneya', function (event, toClone, newclone) {
    toClone.find('select').each(function()
    {
        $(this).chosen();
    });
})
.on('after_append.cloneya', function (event, toClone, newclone) {
    newclone.find('select').each(function()
    {
        $(this).chosen();
    });