Например, если у вас есть какие-либо плагин с конфигурацией, вы можете установить по умолчанию значения и дополнить это с $ .extend
Посмотрите на это:
(function ($) {
$.superPlugin = {
// plugin defaults
defaults:
{
mainClass: 'node',
orientation: 'vertical',
focusEvent: function (event) {
console.log('Focus!');
}
};
};
// plugin code
$.fn.superPlugin = function (fn, options) {
var config = $.extend(true, {}, $.setSelect.defaults, options);
/**
* results: {
* mainClass: 'node',
* orientation: 'horizontal',
* focusEvent: function (event) {
* console.log('Custom focus event!');
* }
* }
*/
};
})(jQuery);
// custom config
var options = {
orientation: 'horizontal',
focusEvent: function (event) {
console.log('Custom focus event!')
}
}
// bind plugin to element
$('.item').superPlugin(options);
ли вы читать документ ation: http: //api.jquery.com/jQuery.fn.extend/ – Yogesh
Возможный дубликат [jquery plugin $ .extend] (http://stackoverflow.com/questions/1898402/jquery-plugin-extend) – Yogesh
Подсказка : научиться использовать [так], это легко: [help] – brasofilo