furf / jquery-ui-touch-punch

A duck punch for adding touch events to jQuery UI
http://touchpunch.furf.com/
3.51k stars 1.33k forks source link

Uncaught TypeError: Cannot read property 'mouse' of undefined #245

Open jon-moreira opened 9 years ago

jon-moreira commented 9 years ago

I'm using the last version of jQuery UI Touch Punch 0.2.3 combined with last jQuery UI 1.11.4 and have the same problem!

Uncaught TypeError: Cannot read property 'mouse' of undefined

@line 21 var mouseProto = $.ui.mouse.prototype, _mouseInit = mouseProto._mouseInit, _mouseDestroy = mouseProto._mouseDestroy, touchHandled;

jQuery UI - v1.11.4

Includes: core.js, widget.js, mouse.js, position.js, draggable.js, droppable.js, resizable.js, selectable.js, sortable.js, slider.js the jquery UI library are included before jquery touch punch.

markvantilburg commented 9 years ago

the jquery UI library are included after jquery touch punch.

First load jquery ui, then load touch punch

jon-moreira commented 9 years ago

Yup. and this is correct.

Sent from my iPhone

On 01 Oct 2015, at 13:03, mark van tilburg notifications@github.com wrote:

the jquery UI library are included after jquery touch punch.

First load jquery ui, then load touch punch

— Reply to this email directly or view it on GitHub.

valeriemettler commented 9 years ago

I was getting this error also, but I was able to fix it by removing remove the async attribute from all of my script tags.

AmolST commented 8 years ago

Yes, I had same issue and resolved by loading js in correct sequence. Thanks markvantilburg !

mdonalisio commented 8 years ago

main-built.js:99 Uncaught TypeError: Cannot read property 'mouse' of undefined

I give that error when generate an uglify file

pavelsc commented 6 years ago

@mdonalisio i have the same issue after uglifying, but only in Firefox. My build config:

({
    appDir: "./panel",
    baseUrl: "./js",
    mainConfigFile: './panel.cfg.js',
    paths: {
        "jquery": "../../libs/jquery-2.1.3.min",
        "jquery.ui": "../../libs/jquery-ui-1.12.1.custom/jquery-ui.min",
        "jquery.ui.touch-punch": "../../libs/jquery.ui.touch-punch",
        "gettext": "../../libs/Gettext",
        "js.cookie": "../../libs/js.cookie",
        "js.plumb": "../../libs/jquery.jsPlumb-1.3.16-all",
        "uuid": "../../libs/uuid",
        "rcswitcher": "../../libs/rcswitcher/js/rcswitcher-4.0",
        "jquery.qtip": "../../libs/jquery.qtip/jquery.qtip.min",
        "jquery.rangeslider": "../../libs/jQRangeSlider-5.7.0/jQRangeSlider.bundle",
        "jquery.form": "../../libs/jquery.form.min",
        "jquery.validate": "../../libs/jquery-validation-1.15.1/dist/jquery.validate.min",
        "intltelinput": "../../libs/intl-tel-input-12.1.9/build/js/intlTelInput.min",
        "intltelinput.utils": "../../libs/intl-tel-input-12.1.9/build/js/utils",
        "mejs": "../../libs/mejs/mediaelement-and-player.min",
        "candy.libs": "../../libs/candy-chat/libs.min",
        "candy": "../../libs/candy-chat/candy.min",
        "jssip": "../../libs/jssip-3.2.4"
    },
    dir: "./panel-built",
    modules: [
        {
            name: "main-built",
            create: true,
            cssPrefix: "../",
            include: ['main']
        }
    ],
    keepBuildDir: false,
    shim: {
        'jquery': {
            exports: 'jQuery'
        },
        "jquery.ui": { deps: ["jquery"], exports: 'jQuery' },
        "jquery.ui.touch-punch": { deps: ["jquery.ui"], exports: 'jQuery' },
        "js.plumb": { deps: ["jquery"] },
        "rcswitcher": { deps: ["jquery"] },
        "jquery.qtip": { deps: ["jquery"] },
        "jquery.rangeslider": { deps: ["jquery", "jquery.ui"] },
        "jquery.form": { deps: ["jquery"] },
        "jquery.valdate": { deps: ["jquery"] },
        "intltelinput": { deps: ["jquery"] },
        "intltelinput.utils": { deps: ["jquery"] },
        "mejs": { deps: ["jquery"] },
        "candy.libs": { deps: ["jquery"] },
        "candy": { deps: ["jquery", "candy.libs"] }
    },
    locale: "en-us",
    optimize: "uglify",
    skipDirOptimize: true,
    generateSourceMaps: true,
    preserveLicenseComments: false,
    normalizeDirDefines: "skip",
    optimizeCss: "standard",
    removeCombined: false,
    inlineText: false,
    useStrict: true
})

I made a workaround with a few lines after detecting touch support:

    if ($.ui === undefined) {
        console.error('jquery.ui required');
        return;
    }

at least that does not block page loading in FF. Also I had the same error in Chrome using microsoft surface. Wrapping in UMD did not help