Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I highligth the matched part of the text? #32

Closed
wbotelhos opened this issue Feb 18, 2016 · 4 comments
Closed

How can I highligth the matched part of the text? #32

wbotelhos opened this issue Feb 18, 2016 · 4 comments

Comments

@wbotelhos
Copy link

I want to type quan and it returns "bevacqua" on the text a choose, like, on key name or email.

May we, in some way, receive the q item here: https://github.com/bevacqua/horsey/blob/master/horsey.js#L150

So a can use replace(q, '<b></b>'), What do you think?

My hack:

render: function(li, suggestion) {
  var keys = ['email', 'name'];

  for (var i = 0; i < keys.length; i++) {
    var
      regex = new RegExp('(' + field.value + ')', 'i'),
      value = suggestion[keys[i]];

    suggestion[keys[i]] = value.replace(regex, '<b>$1</b>');
  }

  li.innerHTML = Templates.users.search(suggestion);
}

If you think all question with some kind of answer is good, I can try to implement a pull request.

@bevacqua
Copy link
Owner

This is on by default now.

@wbotelhos
Copy link
Author

Hi @bevacqua , is there some upgrade tutorial? horsey no more returns a object and so... it would be nice to have some. Thanks.

@bevacqua
Copy link
Owner

Horsey still returns an object. Please check out the demo & updated docs.

@wbotelhos
Copy link
Author

I see, a lot of things changed.
There is some way to turn the case insensitive on?

be -> Bevacqua over be -> bevacqua, since my query on database is insensitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants