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

Issue with drop-down list box and the antiquated IE8 browser #16

Closed
MiArktos opened this Issue Jan 8, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@MiArktos
Contributor

MiArktos commented Jan 8, 2015

Hi,

I use your Typeahead plug-in because
it has a lot of functions out of the box and is very fast.
Thanks for your great plug-in and good documentation and live demos.
Despite the fact that I’m a newbie with JavaScript and jquery it is very easy to use.
It works perfect with Firefox and Chrome browser.
Unfortunately there is an issue with the antiquated IE8, I was not able to fix.

I use jquery-1.11.2.js and typeeahead version 1.7.5 and the meta entry:
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  • Because there is no trim function in IE8 I inserted
if(typeof String.prototype.trim !== 'function') {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, ''); 
  }
}
  • With the option “hint: true” the IE8 hangs, as workaround I disabled this feature.
    You can see this with all demos with hint: true e.g. Beer v1
  • When I try to step through the drop-down list box with the key down
    it automatically select the first item, instead to go through the list.
    The drop-down list box is not removed when I click the submit button
    or press the enter key.

Some additional questions:
Is there a API function to get the latest JSON data obtained from the last Ajax request
like the API in datatables https://datatables.net/reference/api/ajax.json%28%29
When I tried the demo bootstrap v1 I added a callback functions as in demo car v1,
but the callback functions wasn’t triggered.
How does work callbacks if selector options are used?
The callback function OnSubmit has no parameter "obj" as onResult and onClick.
How can I get the latest best match if only the enter key or submit button is pressed?
Is there a option to use the tab key to select a suggestion?

@running-coder

This comment has been minimized.

Owner

running-coder commented Jan 12, 2015

Hey MiArktos,

thanks for the feedback it is really appreciated! For the IE8 trim issue your solution seems appropriate but I might go with jquery trim instead just so no extra code gets added http://api.jquery.com/jquery.trim/

I'll verify:

  • the dropdown behavior with enter / submit
  • the callback functions not being triggered when using custom selectors

Regarding your question "latest JSON data", you are able to add the onResult callback so everytime something is typed inside the search input, this function gets triggered (you can catch the results using the params listed in the documentation)
http://www.runningcoder.org/jquerytypeahead/demo/#form-country_v2

callback: {
        onResult: function (node, query, obj, objCount) {

            var text = "";
            if (query !== "") {
                text = objCount + ' elements matching "' + query + '"';
            }
            $('#result-container').text(text);

        }
}

regarding the onSubmit callback you are right, it should also contain "obj" in param (perhaps i was inconsistent not adding it). I will add it in the next version for sure!

hopefully I have time to work on these changes tonight :)

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