Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7048969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:57:21+00:00 2026-05-28T02:57:21+00:00

I’m using Jquery Mobile pagination plugin and trying to work it into a plugin

  • 0

I’m using Jquery Mobile pagination plugin and trying to work it into a plugin of mine.

Pagination allows to swipe through pages on mobile devices.

My plugin is using a splitscreen, so I’m swiping pages in either one of the panels I’m using. I therefore need to tweak the original plugin to allow:

  1. changing panel pages on click/key press = works
  2. changing panel pages on swipe left/right = does not work

The problem is on swipe the page is not really changing, so I need to mimic everything that happens during a regular jQuery Mobile changePage.

All works ok except for setting the URL to the page being swiped in.

I can grab the page ID but I cannot set it the URL to it. I think this is helpful using dataURL, but I cannot get it to go.

Any help is greatly appreciated!

Here is the respective code from the modified plugin:

snapTo = function( newOffset, immediate ){
   var $newActive = newOffset === 0 ? $page : newOffset > 0 ? $prevPage : $nextPage,
       samePage = !$newActive || $newActive.is( $page ),
       newUrl = samePage && $page.jqmData( "url" ) || $newActive.jqmData( "url"),
       // so I have the new page and it's url when the page is "swiped in"

       // this fires when the swipe is done
       doneCB = function(){ 

           if( !samePage){
              // checking for panel
              if ( $('html').hasClass( "multiview") ) {
                  // ... stuff
                  // I need to set the URL here without triggering a transition

                  } else {
                  //this is how the plugin does it
                  $page.removeClass( $.mobile.activePageClass )

                  //disable hash listening
                  $.mobile.urlHistory.ignoreNextHashChange = true;

                  // pagination uses this but it triggers a changePage, which I don't want
                  $.mobile.path.set( newUrl );

                  //set "toPage" as activePage
                  $.mobile.activePage = $newActive;
                  ... 
                  }
              }

SOLUTION
Not sure if someone has any use for it but here is the solution anyway:

  • you have to call a changePage
  • similar to pagination setting ignoreNextHashChange=true, I need to set a similar blocker inside my own plugin to stop hashChanges from triggering an unwanted transition.

Code inside pagination:

var fakeOptions = {};

fakeOptions.transition="none";
// set a blocker! 
$(_pluginTriggerElement_).plugin("option", "$blockPaginationHashChange", true);

// fire a transition
$.mobile.changePage( $newActive, fakeOptions );

This will fire a changePage without transition. My plugin has a routine similar to JQM in that every changePage also triggers a subsequent hashChange. Just like JQM $ignoreNextHashChange option, I define my own $blockPaginationhashChange option and set up a blocker inside my panel Hashchange routine like so:

// block pagination hashChanges
if ( self.options.$blockPaginationHashChange == true ) {
     self.options.$blockPaginationHashChange = false;
     // stop here
     return;
     }

This way no hashChange reverse transitions fire when pages are being swiped. Very blinky but it works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:57:22+00:00Added an answer on May 28, 2026 at 2:57 am

    I’m not familiar with the plugin you’re using but if you post a link to your site I can probably help a bit more.

    That being said, jQuery Mobile exposes the $.mobile.changePage() function to make changing pages easy.

    $(document).delegate('[data-role="page"]', 'swipeleft swiperight', function (event) {
        event.preventDefault();
        if (event.type == 'swipeleft') {
           $.mobile.changePage(<URL-BASED-ON-SWIPELEFT>, {<options>});
        } else {
           $.mobile.changePage(<URL-BASED-ON-SWIPERIGHT>, {<options>});
        }
    });
    

    Note that <URL-BASED-ON-*> can also be an object that is already in the DOM, like $('#some-page-id').

    Docs for $.mobile.*: http://jquerymobile.com/demos/1.0/docs/api/methods.html

    UPDATE

    How about triggering click events on the left/right arrows when a user swipes, this way you can keep the same logic that the Pagination plugin uses:

    $(document).bind('swipeleft swiperight', function (event) {
        if (event.type == 'swipeleft') {
    
            //swipeleft
            $('.ui-pagination-next').children().trigger('click');
        } else {
    
            //swiperight
            $('.ui-pagination-prev').children().trigger('click');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I am trying to loop through a bunch of documents I have to put
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.