Extend jQuery's .on() to work with mobile touch events

前端 未结 2 1826
孤街浪徒
孤街浪徒 2021-01-02 09:30

I am attempting to use the jQuery mobile events without the rest of jQuery mobile.

https://github.com/jvduf/jquery-mobile-events/blob/master/jquery.mobile.events.js<

2条回答
  •  我在风中等你
    2021-01-02 09:51

    However it does work with .live(), but that is now depreciated.

    So I take it that you want to use event delegation to preserve those events on replaced elements. That would mean that this:

    $('a').on('tap',function () {
        console.log('Hi there!');
    });
    

    would need to change to something like:

    $(document).on('tap', 'a', function () {
        console.log('Hi there!');
    });
    

    in order for it to behave the same as $("a").live("tap", ...

提交回复
热议问题