Cdlist.addons.Search

实例化参数

  • option.btnText 搜索按钮的默认文案

    type: string | defatul: 搜索

  • option.placeholder 输入 input 的 placeholder 内容

    type: string

  • option.val 输入 input 的默认值

    type: string

  • option.regex 检测输入合法性的正则

    type: regex

  • option.historyEnable 是否开启 history 记录模式

    type: bool | default: false

  • option.historyKey history param 参数的 key

    type: string | default: page

  • option.container 插件容器

    type: string

用法

new CdList.addons.Search({
  btnText: '点我吧!',

  placeholder: '需要输入1开头的数字',

  val: '133',

  regex: /^1\d+/,

  historyEnable: true,

  historyKey: 'mysearch',

  container: '#mysearh-wrap'
});

实例方法

在下面的示例中 search 为实例化对象

① search.setValue

设置搜索值,和用户点击搜索按钮效果一致

用法

search.setValue('嗖嗖嗖');

② search.reset

重置搜索内容

用法

search.reset();

事件

在下面的示例中 search 为实例化对象

① search.on('error')

正则验证失败的事件

用法

search.on('error', function (e, value) {
  alert(value + '你输入错了');
});

results matching ""

    No results matching ""