azicchetti / jquerymobile-router

A router/controller for jquery mobile. Also adds support for client-side parameters in the hash part of the url. The routes handles regexp based routes. This plugin can be used alone or (better) with Backbone.js or Spine.js, because it's originally meant to replace their router with something integrated with jQM.
GNU General Public License v2.0
402 stars 69 forks source link

URI parameters are striped out when using new pagebeforechange event #74

Open asxjackal opened 11 years ago

asxjackal commented 11 years ago

Parameters are striped out when using new special pagebeforechange event.

jQueryMobile-router v20130504 jquery.mobile-1.3.1

works fine on jQueryMobile-router v20130416

none-ajaxApp, multipage-template

azicchetti commented 11 years ago

Hi, thanks, fixed!

I'm pushing the fix on the git in a few hours as soon as I've finished testing a small feature, but I'll attach the patch here 'cause it's really trivial:

          $.mobile.changePage(ui.toPage, {
            _jqmrouter_handled: true,
            _jqmrouter_bC: true,
            dataUrl: ui.options.dataUrl
          })

I've just added the dataUrl: ui.options.dataUrl parameter. The patch should be applied inside the bCDeferred.done(function(){ callback.

asxjackal commented 11 years ago

now how does one refresh the page? before i could have called

$.mobile.changePage(hash, { samePageTransition: true, allowSamePageTransition: true, transition: 'none', showLoadMsg: false }); to reload the page.

how can I re-call the eventhandler to reload the page?

azicchetti commented 11 years ago

can't understand the use case. Do you mean a link pointing to the same page?

If that were the case, pagebeforechange is still triggered, although the same-page transition does not happen.

asxjackal commented 11 years ago

Well, if you want to trigger the event without use of a hyperlink but pragmatically based on some logic or user's interaction, that's why jQuery Mobile has $.mobile.changePage(). For instance pull to refresh.

never mind I think i solved it if I do this to pragmatically refresh the page $.mobile.changePage(hash, { samePageTransition: true, allowSamePageTransition: true, transition: 'none', showLoadMsg: false, _jqmrouter_bC: true, dataUrl: $.mobile.path.parseUrl(window.location.href).hash });