扩展qtip或其他选择器插件的属性

时间:2012-12-04 02:43:02

标签: jquery plugins properties extend qtip

我正在尝试为多个qtip实例设置一堆默认属性,但它不起作用。是可能还是我做错了什么?

共同属性

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

实例化#1

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

实例化#2

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

1 个答案:

答案 0 :(得分:2)

在调用qtip插件之前,您必须准备qtip参数。试试这个:

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

$.extend()合并两个或多个对象。 true参数表示它将进行深层复制。第一个对象为空,用于保持原始qtipDefaults不变。