4
假设我想要更改bootstrap-typeahead库中的渲染函数。活跃这一目标 http://twitter.github.com/bootstrap/assets/js/bootstrap-typeahead.js在jQuery库中重新定义方法的最佳方式
一种方法是使:
_.extend($.fn.typeahead.Constructor.prototype, {
render: function (items) {
// some code
}
});
让我们假设我要重新定义渲染功能只为特定元素像...
element.typeahead({
minLength: 3,
source: getSource
});
我应该如何重新定义渲染函数为了只对这个元素有效?
P.S:
我使用jQuery和强调
我试过,但它不工作,因为'$ .fn.typeahead.Constructor.prototype.render'是更改 –
也许你需要深入克隆'$ .fn.typeaheadCustom = $ .extend(true,$ .fn.typeahead,{});' – David
也可以使'$ .extend(true,$ .fn.typeahead,{ });'它不起作用。 –