一:引入样式文件与js
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<script type="text/JavaScript" src="~/Content/js/bootstrap-typeahead.js"></script>
二:建立一个文本框
<input type="text" id="s_mdport" />
注意样式冲突一般该input父级对a的样式可能会影响到他
三:绑定typeahead
五:特殊需求默认提示
六:修改一些样式,宽度,背景色等
效果:
1:修改颜色
把css里边的默认蓝色全部替换成#13c0a2,下次要修改样式直接在这个基础上把#13c0a2全部替换成其他颜色就行了
2:修改宽度
.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:330px;......}
min-width:330p修改成想要的宽度就可以了
3:右边出现文字,就是就是拼一个a标签
});
七:点击时弹出提示
1:要监听点击方法
.on('click', $.proxy(this.click, this)) //要监听点击事件不然就不会执行了
2:点击方法里边做处理,调用回调函数,他默认是在lookup事件里写的,参照他写就可以
click: function (e) { //aj点击时的提示
var items
this.query = this.$element.val()
//if (!this.query || this.query.length < this.options.minLength) { //这个是限制为空就不查询了,取消掉
// return this.shown ? this.hide() : this
//}
if (this.shown == false) {
items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
return items ? this.process(items) : this
}
else
{
var val = this.$menu.find('.active').attr('data-value')
this.$element
.val(this.updater(val))
.change()
return this.hide()
}
//e.stopPropagation()
//e.preventDefault()
//this.select()
//this.$element.focus()
}
一:引入样式文件与js
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<script type="text/JavaScript" src="~/Content/js/bootstrap-typeahead.js"></script>
二:建立一个文本框
<input type="text" id="s_mdport" />
注意样式冲突一般该input父级对a的样式可能会影响到他
三:绑定typeahead
五:特殊需求默认提示
六:修改一些样式,宽度,背景色等
效果:
1:修改颜色
把css里边的默认蓝色全部替换成#13c0a2,下次要修改样式直接在这个基础上把#13c0a2全部替换成其他颜色就行了
2:修改宽度
.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:330px;......}
min-width:330p修改成想要的宽度就可以了
3:右边出现文字,就是就是拼一个a标签
});
七:点击时弹出提示
1:要监听点击方法
.on('click', $.proxy(this.click, this)) //要监听点击事件不然就不会执行了
2:点击方法里边做处理,调用回调函数,他默认是在lookup事件里写的,参照他写就可以
click: function (e) { //aj点击时的提示
var items
this.query = this.$element.val()
//if (!this.query || this.query.length < this.options.minLength) { //这个是限制为空就不查询了,取消掉
// return this.shown ? this.hide() : this
//}
if (this.shown == false) {
items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
return items ? this.process(items) : this
}
else
{
var val = this.$menu.find('.active').attr('data-value')
this.$element
.val(this.updater(val))
.change()
return this.hide()
}
//e.stopPropagation()
//e.preventDefault()
//this.select()
//this.$element.focus()
}