Search code examples
jquerypluginspropertiesextendqtip

Extending properties for qtip or other selector plugin


I am trying to set bunch of default properties for multiple instances of qtip, but it is not working. is it possible or am I doing something wrong?

Common Properties

    var qtipDefaults = {
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'bottomLeft',
                tooltip: 'topLeft'
            }
        },
        style: {
            name: 'dark'
        }
    };

Instantiation # 1

    $('#sbt_name').qtip({
        content: 'This is the Name of the Course'
    }).extend(qtipDefaults);

Instantiation # 2

    var sbt_name = $('#sbt_name').qtip({
        content: 'This is the Name of the Course'
    });
    $.extend(sbt_name, qtipDefaults);

Solution

  • You must prepare qtip parameters before calling qtip plugin. Try this:

    $('#sbt_name').qtip($.extend(true, {}, qtipDefaults, {
        content: 'This is the Name of the Course'
    }));
    

    $.extend() merges two or more objects. true parameter indicates it will make deep copy. First object is empty, for keeping original qtipDefaults unchanged.