0

I am trying to use yepnope with Modernizr and Hammer.js to detect and trigger touch events for a slider. This is my code. I have two errors in console and don't manage to debug. Plus I don't understand where this <error comes from. If I remove the following bit of code, both errors disappear.

Any clue?

var slider = $('#featured');

yepnope({
test: Modernizr.touch,
yep: [ "/assets/javascripts/jquery.hammer.js", "/assets/javascripts/hammer.js"],
nope: [''],
complete: function () {
        slider.hammer({drag: false}).bind("swipe", function (ev) {
        if(ev.direction === 'left'){
            slider.trigger("orbit.next");
        } else if(ev.direction === 'right'){
            slider.trigger("orbit.prev");
            }
        });
    }
});

I have the following errors in my console.

SyntaxError: Unexpected token '<'
TypeError: 'undefined' is not a function (evaluating 'slider.hammer({drag: false})')
4

1 回答 1

0

检查这两个网址...“/assets/javascripts/jquery.hammer.js”、“/assets/javascripts/hammer.js”

我猜其中一个正在返回一个 html 页面,可能是一个错误页面。

此外,按 F12 打开网络选项卡并检查任何其他 .js 文件是否未作为 html 加载。

于 2013-04-01T10:16:10.950 回答