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

Difficulty with IE. #148

Closed
nathanhokanson opened this Issue Feb 9, 2016 · 11 comments

Comments

Projects
None yet
2 participants
@nathanhokanson

nathanhokanson commented Feb 9, 2016

I am importing the jquery.typeahead via requirejs in the following manner:

var require = {
  shim: {
    'jquery' : {
      exports: "window.jQuery"
    },
    .....
            'libraries/jquery.typeahead.min' : {
            deps:['jquery'],
            init: function($) {
              return require.s.contexts._.registry['jquery.typeahead.min'].factory($);
            }
        }
    },
    paths: {
       'jquery': "libraries/jquery-1.10.2",
        'libraries/jquery.typeahead.min':'libraries/jquery.typeahead.min'
@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 9, 2016

hey nathan, I'm not familiar with all requireJs subtilities but mine looks like:

var require = {
    waitSeconds: 0,
    paths: {

        'jquery': '../plugin/jquery/dist/jquery.min',
        'bootstrap': '../plugin/bootstrap/dist/js/bootstrap.min',

        'angular': '../plugin/angular/angular.min',
        'jquery-typeahead': '../plugin/jquery-typeahead/dist/jquery.typeahead.min'

    },
    shim: {
        'bootstrap': {deps: ['jquery']},

        'angular': {'exports': 'angular', deps: ['jquery']},
        'jquery-typeahead': {deps: ['jquery']}
    },
    priority: [
        'jquery',
        'bootstrap',
        'angular'
    ]
};

What is the issue / thrown error?

@nathanhokanson

This comment has been minimized.

nathanhokanson commented Feb 9, 2016

Sorry, the post is incomplete. Let me try again:

The thrown error is: SCRIPT438: Object doesn't support property or method 'typeahead'

The definition of my file that uses the typeahead is:

define(['libraries/jquery.typeahead.min'
],
function(TypeAhead){
// Down in the code I am calling:
$.typeahead({input:"#templateName", .... });
// I have also tried $("#templateName").typeahead({ .... })
}
}

The error occurs at the line where I actually call .typeahead.

Sometimes it succeeds when I reload the page, but also sometimes not.
It works fine in Chrome and Firefox. I hate IE.

@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 9, 2016

I was able to reproduce the issue using jquery 2.x+ as a dependency, you should either use 1.x or add the jquery migrate file

@nathanhokanson

This comment has been minimized.

nathanhokanson commented Feb 9, 2016

We are using jquery 1.10.2.

@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 9, 2016

I can see typeahead is missing a return value

return $.proxy($.typeahead, Typeahead);

but perhaps that's a different issue... the above fix solves

define(["jquery", "jquery-typeahead"], function($, Typeahead) {

    console.log('~~~~~~~~~')
    console.log($)
    console.log(Typeahead) // Was undefined since the plugin had no returned value
    console.log('~~~~~~~~~')

@running-coder running-coder added the Bug label Feb 9, 2016

@running-coder running-coder added this to the 2.3.4 milestone Feb 9, 2016

@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 9, 2016

let me know if it solved your issue

define(["jquery-typeahead"], function(Typeahead) {

    Typeahead({input:"#templateName", .... })
});

@running-coder running-coder removed the Support label Feb 9, 2016

@nathanhokanson

This comment has been minimized.

nathanhokanson commented Feb 10, 2016

Whew! That fixed the problem! Thanks!

When will this version be available in a minified format?

@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 10, 2016

Cool! the .min should be committed inside the /dist folder inside the develop branch, https://github.com/running-coder/jquery-typeahead/tree/develop/dist

version 2.3.4 should be available by the end of the week, I still have to squeeze in a couple things

@nathanhokanson

This comment has been minimized.

nathanhokanson commented Feb 10, 2016

Thanks again for this plugin and all your hard work!

@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 10, 2016

yw good sir, thanks for raising the issue!

running-coder pushed a commit that referenced this issue Feb 11, 2016

tom bertrand
Version 2.3.4
Improved Feature
#150 Add an option to ``resultContainer`` to prevent from building the HTML result list

Fixes
#146 stopPropagation() prevents from catching a click at the document level
#148 Typeahead needed to return the Class for RequireJS
#151 Slugify should be an option, not enforced on ``href`` option

Note
#152 Convert CSS file to SCSS (phase 1, no variables)
#153 Replace Grunt with Gulp ES6
Added a new demo ``navigation_v1``

running-coder added a commit that referenced this issue Mar 26, 2016

@running-coder

This comment has been minimized.

Owner

running-coder commented Mar 26, 2016

I've made a mistake... please update your code when 2.4.0 is released

define(["jquery-typeahead"], function(Typeahead) {

    $.typeahead({input:"#templateName", .... })
});

running-coder added a commit that referenced this issue Mar 26, 2016

Version 2.4.0
Features
- #160 if onSubmit callback returns true, the form should be submitted with a regular browser submit
Fixes
- #166 Different browsers do not have the same behaviors when pressing "Esc" key when the input is focused
- #165 Submitting form with typeahead inside (hideLayout called multiple times)
- #161 Fixed missing X icon when using bootstrap css
Notes
- #170 jquery-typeahead as a npm package
- #169 Add basic unit tests
- #148 Updated Typeahead AMD, please review requirejs_v1 example
- Abandonned Dynamic Source Switching option. Would have to handle too many custom case, instead the sources should be loaded and a matcher function should be used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment