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

Avoid dropdown closing #731

Closed
pensiero opened this issue Mar 3, 2014 · 14 comments
Closed

Avoid dropdown closing #731

pensiero opened this issue Mar 3, 2014 · 14 comments

Comments

@pensiero
Copy link

pensiero commented Mar 3, 2014

How to accomplish it with the new version? Before 0.10 I did:

$(element).data("ttView").dropdownView.close = function() { };
$(element).parent().click(function(e) {
    e.stopPropagation();
});
$('body').click(function() {
    $(element).typeahead('val', '');
});

But now it doesn't work.

Thanks fot the replies

@braydie
Copy link

braydie commented Mar 3, 2014

I've been digging around through the issues and cannot figure out how to do the same. Stumbled across issue #646, which seems to be the most recent attempt at someone trying to do this. Couldn't get any results from it for me, but you may have more luck than me!

@pensiero
Copy link
Author

pensiero commented Mar 3, 2014

I'm not very good with this kind of things. However, I think that the problem is only here:
$(element).data("ttView").dropdownView.close = function() { };

I have to "empty" the close method of dropdown. Where can i access to it in the new code? I saw that dropdownView doesn't exists, but there is something called dropdown.

@O-Mutt
Copy link

O-Mutt commented Mar 5, 2014

you could do a
$(typeahead).on('blur', funtion(event) { event.stopPropagation(); }
I believe

@braydie
Copy link

braydie commented Mar 6, 2014

@Mutmatt,I've just tried what you've suggested and I couldn't get it to stop the dropdown closing. I added console.log to the function to see if it was being hit and it wasn't.. I've searched all over github and the web looking for how to do this in 0.10.x but cannot find anything that is up to date.

@jharding
Copy link
Contributor

jharding commented Mar 7, 2014

I don't recommend this as this is very likely to break in the future since you're messing around with the internals of typeahead.js, but if you change $(element).data("ttView").dropdownView.close to $(element).data('ttTypeahead').dropdown.close, your hack may start to work again.

@pensiero
Copy link
Author

pensiero commented Mar 7, 2014

Thanks a lot, Jake
Il 07/mar/2014 08:46 "Jake Harding" notifications@github.com ha scritto:

I don't recommend this as this is very likely to break in the future since
you're messing around with the internals of typeahead.js, but if you change
$(element).data("ttView").dropdownView.close to
$(element).data('ttTypeahead').dropdown.close, your hack may start to
work again.

Reply to this email directly or view it on GitHubhttps://github.com//issues/731#issuecomment-36974643
.

@jharding jharding closed this as completed Mar 7, 2014
@jstejada
Copy link

should there be an option to prevent the dropdown from closing?

@jharding
Copy link
Contributor

@jstejada so behavior are you looking to achieve? You want the menu to always be open?

@jstejada
Copy link

jstejada commented May 1, 2015

@jharding exactly! I want to be able to select multiple options, so I need to be able to select without closing the dropdown menu.

thanks!

@worleydl
Copy link

Seconded. I'd like to support clicking an element to show more data about a row but the default behavior is to select the clicked row and close out the dropdown.

@worleydl
Copy link

Well putting a click handler in and stopping the propagation works too, so I don't know if it's necessary to mod the library.

@jdrorrer
Copy link

jdrorrer commented Jun 8, 2015

@worleydl What did you hook the click handler up to? I am trying to do the same thing on the suggestion, the menu, and the dataset, but stopPropogation() is not working for me. Thank you!

@worleydl
Copy link

worleydl commented Jun 8, 2015

@jdrorrer I'm using an tag for my row template. Setting up a click handler at that level and stopping propagation prevents the dropdown from being closed.

@jdrorrer
Copy link

jdrorrer commented Jun 8, 2015

@worleydl For whatever reason, I couldn't get that to work. However, this did the trick for me: .tt-menu {display: block !important;} Thanks again!

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

No branches or pull requests

7 participants