magnificpopup работает только при втором щелчке при вызове встроенного ajax

Я пытаюсь вызвать локальную веб-страницу для загрузки внутри оверлея magnificpopup, но это происходит только при втором щелчке.

На вкладке моей сети я вижу, что она запрашивает эту страницу, но не запускает оверлей и не загружает этот html до второго щелчка.

Я новичок в JS, поэтому я не совсем уверен, что мне нужно делать, поэтому любые указатели будут оценены!

Component.prototype = {

    init: function () {
        var that = this;

        this.$element.on('click tap',function(e){
            e.preventDefault();
            that._galleryId = that.$element.attr('href'); //get the url from the link we've just clicked
            that._initialiseGallery(that);

        });

    },
    _onGalleryOpen: function(that){
        console.log('test5');
        if(that.options.fullScreenType === 'image'){
            $(window).trigger('resize');
        }
    },

    _initialiseGallery: function(that) {

        that.$element.magnificPopup({
          items: {
            src: that._galleryId
          },
          type: 'ajax',

            callbacks: {
                open: function() {
                    that._onGalleryOpen(that);
                },
                close: function() {
                  // Will fire when popup is closed
                },
              parseAjax: function(mfpResponse) {
                // mfpResponse.data is a "data" object from ajax "success" callback
                // for simple HTML file, it will be just String
                // You may modify it to change contents of the popup
                // For example, to show just #some-element:
                mfpResponse.data = $(mfpResponse.data).find('.Gallery');

              },
              ajaxContentAdded: function() {
                // Ajax content is loaded and appended to DOM
              }
            }
        });
    }
}

person tjcss    schedule 04.02.2014    source источник


Ответы (1)


Так меняется:

that.$element.magnificPopup({

to:

$.magnificPopup.open({...});

работал!

Я нашел решение здесь: Magnific-popup не работает чтобы открыть с помощью кнопки внутри информационного окна Google Maps

person tjcss    schedule 04.02.2014