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

Passing the $element as context to itemSelected #41

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from

Conversation

VictorGarcia
Copy link

With the current implementation it is not possible to access this.$element
from the itemSelected function. This comes handy when implementing
several typeaheads in the same page and you need to react in other elements
once the typeahead was selected. By using proxy we are passing the current
element in the context and it can be accessed as 'this' from within 
itemSelected. 

Example:
[...]
itemSelected: function (item) {
    $(this).prev('input[type="hidden"]').val(item);
},
[...]

With the current implementation it is not possible to access this.$element
from the itemSelected function. This comes handy when implementing
several typeaheads in the same page and you need to react in other elements
once the typeahead was selected. By using proxy we are passing the current
element in the context and it can be accessed as 'this' from within 
itemSelected. 

Example:
[...]
itemSelected: function (item) {
    $(this).prev('input[type="hidden"]').val(item);
},
[...]
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

Successfully merging this pull request may close these issues.

1 participant