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

Add destroy method #59

Merged
merged 3 commits into from
Feb 28, 2013

Conversation

jharding
Copy link
Contributor

This will allow typeaheads to be reinitialized:

// create
$('.typeahead').typeahead({ /* ... */ });

// destroy
$('.typeahead').typeahead('destroy');

// create again, this time with different datasets/settings
$('.typeahead').typeahead({ /* ... */ });

I need to add some tests, but the code should be good to go. It'll fix #41.

Also, I fixed a bug that prevented the undocumented ttl_ms option from being set to 0.

.on('mouseleave', this._handleMouseleave)
.on('mouseover', '.tt-suggestions > .tt-suggestion', this._handleMouseover)
.on('click', '.tt-suggestions > .tt-suggestion', this._handleSelection);
.on('mouseenter.tt', this._handleMouseenter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a suffix instead of a prefix? Does this.$menu.off('.tt'); not work with prefixes? Just curious because I haven't seen this before…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the link.

@timtrueman
Copy link
Contributor

Looks good. Do you think this is worth testing if we can only test each individual destroy method and not the whole?

@jharding
Copy link
Contributor Author

I was going to use this to start a little integration test suite... we'll see how that goes.

@timtrueman
Copy link
Contributor

Sounds good. Would that be something that could run in Travis?

@jharding
Copy link
Contributor Author

Yeah, it'd still be written using Jasmine. Basically I would just initialize typeaheads and inspect some properties to make sure things are as expected. It'd be pretty dumb, but it'd probably be useful to have.

@jharding
Copy link
Contributor Author

Eh might hold off on the integration tests, for now I just added some unit tests.

jharding added a commit that referenced this pull request Feb 28, 2013
@jharding jharding merged commit c5ac72c into twitter:integration-0.8.2 Feb 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants