如何更改jquery.mentionsInput(jquery插件)中的默认选项?

时间:2012-12-12 11:31:09

标签: javascript jquery jquery-plugins default options

如何更改jquery.mentionsInput(jquery插件)中的默认选项

(function ($, _, undefined) {

  // Settings
  var defaultSettings = {
    triggerChar   : '@',
    onDataRequest : $.noop,
    minChars      : 2,
    showAvatars   : true,
    elastic       : true,
    classes       : {
      autoCompleteItemActive : "active"
    },
    templates     : {
      wrapper                    : _.template('<div class="mentions-input-box"></div>'),
      autocompleteList           : _.template('<div class="mentions-autocomplete-list"></div>')
    }
  };
....

如何从

设置其他triggerChar值
  $('textarea.mention, input.mention').mentionsInput({

    onDataRequest:function (mode, query, callback) {
      var data = [
        { id:1, name:'Kenneth Auchenberg', 'avatar':'http://cdn0.4dots.com/i/customavatars/avatar7112_1.gif', 'type':'contact' }
      ];
    }
  });

1 个答案:

答案 0 :(得分:1)

docs设置triggerChar,例如

$('textarea.mention, input.mention').mentionsInput({

  onDataRequest: function(){},
  triggerChar: '#'
});