假设我想要更改bootstrap-typeahead库中的呈现函数。http://twitter.github.com/bootstrap/assets/js/bootstrap-typeahead.js
激活此目标的一种方法是:
_.extend($.fn.typeahead.Constructor.prototype, {
render: function (items) {
// some code
}
});假设我只想为…这样的特定元素重新定义呈现函数
element.typeahead({
minLength: 3,
source: getSource
});我应该如何重新定义渲染函数,才能使其仅对此元素有效?
附言:
我使用jquery和下划线
发布于 2012-08-30 17:54:37
也许你可以先克隆它?
$.fn.typeaheadCustom = $.fn.typeahead;
_.extend($.fn.typeaheadCustom.Constructor.prototype, {
render: function (items) {
// some code
}
});
element.typeaheadCustom({
minLength: 3,
source: getSource
});更新
您可能需要对其进行深度克隆:
$.fn.typeaheadCustom = $.extend(true, $.fn.typeahead, {});https://stackoverflow.com/questions/12194171
复制相似问题