fsjuhl / mobile-bookmark-bubble

Automatically exported from code.google.com/p/mobile-bookmark-bubble
Apache License 2.0
0 stars 0 forks source link

Hash parameter conflicts with jQuery mobile #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Write a jQuery Mobile page
2. Use the mobile-bookmark-bubble script with the example ?bmb=1 hash param

What is the expected output? What do you see instead?

Ideally, it would not conflict.  Since jQuery Mobile uses hash params as a page 
addressing scheme, the usage of hash parameter here conflicts, and jquery 
mobile tries to load a page via xhr e.g. "HTTP GET /bmb=1".

What version of the product are you using? On what operating system?

Latest HG head.  iOS 4.x.

Please provide any additional information below.

I used a local variable instead, but am not completely familiar with the 
ramifications.  I'm not sure where/if this behavior should be changed or just 
documented.

$(document).ready(function() {
  setTimeout(function() {
    var bubble = new google.bookmarkbubble.Bubble();

    var varForHashParameter = false;

    bubble.hasHashParameter = function() {
      return varForHashParameter;
    };

    bubble.setHashParameter = function() {
      varForHashParameter = true;
    };

    bubble.showIfAllowed();

  }, 1000);
});

Original issue reported on code.google.com by jason.p.morrison on 20 Dec 2010 at 10:57

GoogleCodeExporter commented 9 years ago
jQuery mobile's usage of location.hash for page addressing, history, navigation:

http://jquerymobile.com/demos/1.0a2/#docs/pages/docs-navmodel.html

Original comment by jason.p.morrison on 20 Dec 2010 at 10:58

GoogleCodeExporter commented 9 years ago
Sorry for the late response -- I've been away on holidays for the past couple 
weeks.

The idea behind using a hash parameter is that it will persist in the URL 
across browser reloads and will be saved with any bookmark the user creates. 
This lets you do things like:
a) detect when the user has bookmarked your app after seeing the bubble, so you 
can track the effectiveness of the promo
b) avoid showing the bubble if the user has already seen it

There's a risk of a poor user experience if you just use a local variable: if 
the user bookmarks your application and then comes back later by tapping on the 
bookmark, they may see the bubble again, prompting them to bookmark your 
application -- but they've already done that.

I've pushed a documentation update noting that this conflicts with jQuery 
Mobile.

Original comment by ntho...@google.com on 4 Jan 2011 at 5:46

GoogleCodeExporter commented 9 years ago
Issue 9 has been merged into this issue.

Original comment by ntho...@google.com on 18 Jan 2011 at 1:57

GoogleCodeExporter commented 9 years ago
As a workaround, I use the HTML5 history object to adjust the URL without a 
page refresh, and without using the hash tag.  This seems to work for me.  See 
below for code:

var parameter = 'bmb=1';

bubble.hasHashParameter = function () {
  return window.location.search.indexOf(parameter) != -1;
};

bubble.setHashParameter = function () {
  if (!this.hasHashParameter()) {
    if (window.location.search.indexOf('?') == -1) {
      window.history.replaceState('Object', 'Title', window.location + '?' + parameter);
    } else {
      window.history.replaceState('Object', 'Title', window.location + '&' + parameter);
    }
  }
};

Original comment by AndrewKo...@gmail.com on 28 Jul 2012 at 3:41