Loading dynamic AJAX content into Fancybox

前端 未结 9 1374
夕颜
夕颜 2020-12-17 22:47

This scenario:

The user inserts his zip into an input-field, and when clicking the magic button, he gets to see stores closest to his location. I ca

相关标签:
9条回答
  • 2020-12-17 23:40

    I was interested in doing the same thing. I came to a similar solution, however it's different than any others recommended here. After looking at the documentation for both API's, this should work in V1 or V2.

    $('#button').on('click', function(){    
        $('#foo').load('/content.html', function(){
    
            var $source = $(this);
    
            $.fancybox({
                content: $source,
                width: 550,
                title: 'Your Title',
                etc...
            });
        });
    });
    

    Then, your container for the data.

    <div id="foo" style="display: none;"></div>
    
    0 讨论(0)
  • 2020-12-17 23:44

    Try:

    $.fancybox({
      type: 'ajax',
      ajax: { 
         url: nzData
        }
    });
    
    0 讨论(0)
  • 2020-12-17 23:45

    I know this is an old question, but I've recently had to deal with something similar. Here is what I did to load ajax into fancybox.

    $('#button').on('click', function(){
        $.fancybox({
            width: 400,
            height: 400,
            autoSize: false,
            href: '/some/url-to-load',
            type: 'ajax'
        });
    });
    
    0 讨论(0)
提交回复
热议问题