var changeSlide = function( toSlide){ if(toSlide.length) $.mobile.changePage( toSlide, { transition: toSlide.jqmData('transition') } ); }; // Return to homepage var getHomeSlide = function(){ return $(':jqmData(role=page):first'); }; // go home var goHome = function(){ changeSlide( getHomeSlide() ); return false; }; // Go to the next page var getNextSlide = function(slide){ return slide.next(' :jqmData(role=page)'); }; //Go to the next page var goForward = function(){ changeSlide( getNextSlide($.mobile.activePage) ); return false; }; //Get the previous page var getPrevSlide = function(slide){ return slide.prev(':jqmData(role=page)'); }; // Jump to the previous page var goBack = function(){ changeSlide( getPrevSlide($.mobile.activePage) ); return false; };
Note that the $.mobile.changePage method is used to achieve page jump, and the jump has a jump effect parameter, such as: //transition to the "about us" page with a slideup transition $.mobile.changePage( "about/us.html", { transition: "slideup"} ); //transition to the "search results" page , using data from a form with an id of "search" $.mobile.changePage( "searchresults.php", { type: "post", data: $("form#search" ).serialize() }); In return $(':jqmData(role=page):first');, jqmData actually replaces jquery's data selector. 4. Another one is the processing of left and right arrow keys, such as :
5. Processing of navigation bar When each slide is loaded, the navigation bar is automatically loaded into the footer part of the page. This should be loaded before 'pagebeforecreate' ,
var loadImages = function(slide) { var width = $(window ).width();//화면 크기에 따라 이미지 크기를 판단합니다. var attrName = width > 'large' : 'small' $('img:jqmData(' attrName ')', 슬라이드).each(function(){ var img = $ (this); var source = img.jqmData(attrName); if(source) img.attr(' src', source).jqmRemoveData(attrName); }); } ;
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn