Dynamic html page creation with jquery

后端 未结 3 402
醉梦人生
醉梦人生 2021-01-17 01:51

I will try to keep this post the shortest possible.

I am trying to create a jquery mobile web-page where , i import the photos and albums from a facebook page , usin

相关标签:
3条回答
  • 2021-01-17 02:29

    Binding events to dynamically create items should be like this.

    $(document).on('event', '.element', function () { magic });
    

    Demo

    This code applies for all types of dynamic elements.

    Another important note, don't use .ready / $(function($) with jQuery Mobile. Use jQuery Mobile events.

    0 讨论(0)
  • 2021-01-17 02:38

    You must change where you use live by on

    $(document)
        .on('pageshow', 'div.gallery-page', function(e){
            var
                    currentPage = $(e.target),
                    options = {},
                    photoSwipeInstance = $("ul.gallery a", e.target).photoSwipe(options,  currentPage.attr('id'));
            return true;
        })
    
        .on('pagehide', 'div.gallery-page', function(e){
            var 
                currentPage = $(e.target),
                photoSwipeInstance = PhotoSwipe.getInstance(currentPage.attr('id'));
    
            if (typeof photoSwipeInstance != "undefined" && photoSwipeInstance != null) {
                 PhotoSwipe.detatch(photoSwipeInstance);
            }
    
            return true;
    
        });
    
    });
    

    documentation: http://api.jquery.com/on/

    0 讨论(0)
  • 2021-01-17 02:39

    live() is removed from jQuery 1.9, and I see this tag in your code.

    jquery-1.9.1.min.js
    
    0 讨论(0)
提交回复
热议问题