如何使用jquery-mobile界面在photoswipe中使用事件处理程序

Bri*_*ian 2 jquery-plugins jquery-mobile phonegap-plugins photoswipe

我试图做一些图像处理的东西取决于我与我的画廊关联的任意数据.

  gallery.html('');
    $.each(data.photos, function(key, photo) {

        var item = "<li><a href='http://stage.domain.com/assets/img/user/"+photo.full+"'><img src='http://stage.domain.com/assets/img/user/"+photo.med+"'/></a></li>";

        gallery.append(item);
    });
    gallery.trigger('create');

    var options = {


        enableMouseWheel: false , 
        enableKeyboard: false ,
        captionAndToolbarAutoHideDelay:0,
        jQueryMobile:true

    }

    var swipe = $(".gallery a").photoSwipe(options);

    // onDisplayImage
    swipe.addEventHandler(PhotoSwipe.EventTypes.onDisplayImage, function(e){
        console.log('onDisplayImage{');
        console.log('onDisplayImage - e.action = ' + e.action);
        console.log('onDisplayImage - e.index = ' + e.index);
        console.log(swipe.getCurrentImage());
        console.log('onDisplayImage}');
    });
Run Code Online (Sandbox Code Playgroud)

但是ondisplayimage事件从未被解雇,因为没有定义PhotoSwipe

 06-14 04:28:45.496: D/CordovaLog(31662): Uncaught ReferenceError: PhotoSwipe is not defined
Run Code Online (Sandbox Code Playgroud)

示例https://github.com/codecomputerlove/PhotoSwipe/blob/master/src/examples/07-custom-toolbar.html不使用我需要的jquery实现.那么基本上我如何使用jquery mobile挂钩事件处理程序.

小智 6

更改:

swipe.addEventHandler(PhotoSwipe.EventTypes.onDisplayImage, function(e){
Run Code Online (Sandbox Code Playgroud)

至:

swipe.addEventHandler(window.Code.PhotoSwipe.EventTypes.onDisplayImage, function(e){
Run Code Online (Sandbox Code Playgroud)

我正在使用jQuery编写内容并直接调用类来解决问题.