Bootstrap   发布时间:2022-04-18  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了twitter-bootstrap – 如何在多个属性上搜索对象(knockout.js twitter bootstrap typeahead)?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在这一点上:)

http://blogs.msdn.com/b/rebond/archive/2012/07/18/knockout-js-binding-for-bootstrap-typeahead-plugin.aspx

// Bootstrap.Typeahead binding: presently requires custom version from gist: https://gist.github.com/1866577.
// Use like so: data-bind="typeahead: { target: SELEctedNamespace,source: namespaces }"
ko.bindingHandlers.typeahead = {
  init: function(element,valueAccessor) {
  var binding = this;
  var elem = $(element);
  var value = valueAccessor();

  // Setup Bootstrap Typeahead for this element.
  elem.typeahead(
  {
    source: function() { return ko.utilS.UnwrapObservable(value.sourcE); },onSELEct: function(val) { value.target(val); }
  });

// Set the value of the target when the field is blurred.
elem.blur(function() { value.target(elem.val()); });
  },update: function(element,valueAccessor) {
var elem = $(element);
var value = valueAccessor();
elem.val(value.target());
  }
 };

我有X类,有4个属性.

我想在其3个属性搜索X对象数组. (其他财产是id)

任何的想法?

解决方法

在.typeahead调用中,传递一个将查看其他属性matcher function
elem.typeahead({
   source: function() { return ko.utilS.UnwrapObservable(value.sourcE); },onSELEct: function(val) { value.target(val); },matcher: function(item) {
      // check if it matches Foo,Bar,or Baz properties.
      return item.Foo.indexOf(this.query) >= 0 || item.bar.indexOf(this.query) >= 0 || item.baz.indexOf(this.query) >= 0;
   }
});

大佬总结

以上是大佬教程为你收集整理的twitter-bootstrap – 如何在多个属性上搜索对象(knockout.js twitter bootstrap typeahead)?全部内容,希望文章能够帮你解决twitter-bootstrap – 如何在多个属性上搜索对象(knockout.js twitter bootstrap typeahead)?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。