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

onLayoutBuiltBefore: window.Typeahead['#name-match-input']['hintIndex'] returns null #94

Closed
sdillinger opened this Issue Oct 21, 2015 · 6 comments

Comments

Projects
None yet
2 participants
@sdillinger

sdillinger commented Oct 21, 2015

I have a setup where the user can search by initials or name. I want to highlight the current hinted selection. In my case the hinted selection isn't always the first selection.

Like here:

image

To fix this I do the following in onLayoutBulidBefore:

//get the index of the hinted record
var index = window.Typeahead['#name-match-input']['hintIndex'];

//remove the element from dom & style it
var hinted_el = resultHtmlList.find('li a[data-index="' + index + '"]').parents('li').addClass('top-selection').detach();

//add back to top of list
$(hinted_el).prependTo(resultHtmlList);

Problem:

On entry of the first query letter ('m' above) this line:

var index = window.Typeahead['#name-match-input']['hintIndex'];

return null;

For all subsequent letters it returns the correct index.

image

As a side note I think the hinted selection should be the first one in the list by default- not a big deal really, just a gut feeling.

Thanks.

@sdillinger

This comment has been minimized.

sdillinger commented Oct 21, 2015

update:

Playing with this a bit more it seems the hintIndex is indeterminate. Using the example above. If I search mu I get an hintIndex of 1.

image

values in onLayoutBuiltBefore:

image

@running-coder

This comment has been minimized.

Owner

running-coder commented Oct 21, 2015

hey sdillinger,

I think the issue was caused by the fact that the callback was triggered before assigning the hintIndex. So everytime you would receive it, it would be the hint index of the previous search and not the current one.

Let me know

Thanks.

@sdillinger

This comment has been minimized.

sdillinger commented Oct 21, 2015

That could definitely be the issue.

Any suggestions on how to handle this?​

On Wed, Oct 21, 2015 at 5:20 PM, Tom Bertrand notifications@github.com
wrote:

hey dillinger,

I think your issue was caused by the fact that the callback was called
before assigning the hintIndex. So everytime you would receive it, it would
be the hint index of the previous search and not the current one.

Let me know

Thanks.


Reply to this email directly or view it on GitHub
#94 (comment)
.

Steve Dillinger
Founder & CEO

CIQ Labs - ClassroomIQ
222 Merchandise Mart Plaza
Suite 1212
Chicago, IL 60654

steve@ciqlabs.com
(312) 804-4799

www.getclassroomiq.com http://www.classroom-iq.com

@running-coder

This comment has been minimized.

Owner

running-coder commented Oct 21, 2015

Try to update to the latest master branch code, I've pushed a potential fix

@sdillinger

This comment has been minimized.

sdillinger commented Oct 22, 2015

While I haven't done crazy robust testing, it seems to be working now.

Thanks for the quick support!!

@sdillinger sdillinger closed this Oct 22, 2015

@running-coder

This comment has been minimized.

Owner

running-coder commented Oct 22, 2015

Cool! Glad I don't have to re-tag 2.1.3 hehe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment