Search code examples
clickjquerycolor-picker

Bind color picker plugin to click function


I'm trying to bind a jQuery plugin called miniColors ( http://bit.ly/Mq88mU ) to a click function I have, to add slides to a slide manager. I can't seem to figure out how to bind it right. Any ideas?

This is my add slide function

el.on('click', '.addSlide', function (e) {
    e.preventDefault();
    var templ = $('#slideTemplate').html();
    var id = parseInt( $('ul.ui-sortable li').last().find('.order').val() ) || 0;
    var slide = templ.replace(/%id%/g, id).replace(/%id1%/g, id + 1);
    $(templ).find('.minicolors').minicolors();
    $(slide).hide().insertAfter($('ul.ui-sortable li').last()).fadeIn(300);
});

Solution

  • Not sure if this is the correct way to accomplish it, but by using the fadeIn function I have been able to accomplish what I intended.

    $(slide).hide().insertAfter($('ul.ui-sortable li').last()).fadeIn(function(){
        $(this).find('.minicolors').minicolors();
    });