5

jQuery BBQ noob question: I have downloaded jQuery BBQ 1.2.1 and I'm trying to use it with jQuery 2.1.0. BBQ works in the sense that it does what I want it to do, but I've noticed an error message in the console. I've tracked it down to what appears to be a compatibility issue. Here's a sample HTML page that produces the error:

<!DOCTYPE HTML>
<html>
    <head>
        <title>example</title>
    </head>
    <body>
        example
    </body>
    <script src="../js/lib/jquery-2.1.0.min.js"></script>
    <script src="../js/lib/jquery.ba-bbq.min.js"></script>
</html>

In Firefox the console error is TypeError: f is undefined. In Chrome the error is different: Uncaught TypeError: Cannot read property 'msie' of undefined.

I've noticed jQuery BBQ is pretty old. Is there a newer rev of jQuery BBQ? Or is there some newer replacement library?

UPDATE

I'm using jQuery BBQ because a google search sent me to this previously answered question: Parsing URL hash/fragment identifier with JavaScript. The real issue I'm trying to solve is the same as the linked question: to respond to changes in the hash portion of the URI and to parse that fragment.

It turns out that for my purposes (so far), I can eliminate jQuery BBQ and write a couple of lines of code to grab the hash string (and remove the hash sign):

    $(window).bind('hashchange', function() {
        var hashString = window.location.hash || '';
        hashString = hashString.replace("#",'');
        myEventHandler(hashString);
    });

So that will work for now. It's pretty simple and it's one less module dependency, so win-win. I suppose that's why there were no responses to a jQuery-BBQ question, eh?

Community
  • 1
  • 1
Lee Jenkins
  • 2,299
  • 3
  • 24
  • 39
  • possible duplicate of [browser.msie error after update to jQuery 1.9.1](http://stackoverflow.com/questions/14892095/browser-msie-error-after-update-to-jquery-1-9-1) – Phil Apr 16 '14 at 03:12
  • 1
    I respectfully disagree. It would be a duplicate if the question had been asked by the jQuery-BBQ maintainer -- and apparently there isn't one. And while hand-patching a 3rd party component is not off the table, it's far simpler not to use jQuery-BBQ and instead use `window.location.hash`. – Lee Jenkins Apr 17 '14 at 02:21

2 Answers2

3

I am glad that your problem was solved(1 year ago!). But for anybody else who has this problem:

As you may have seen in this answer this problem is caused by $.browser which was deprecated in version 1.3 and removed in 1.9.

but you can fix that quite simply. just open jquery bbq source and search for f.msie (used like h = f.msie ) and replace it with:

( navigator.appName == 'Microsoft Internet Explorer') ? true : false

(now you must have h = ( navigator.appName == 'Microsoft Internet Explorer') ? true : false )

Community
  • 1
  • 1
samad montazeri
  • 1,203
  • 16
  • 28
0

The syntax that worked for me was:

h = ( navigator.appName == 'Microsoft Internet Explorer' ? true : false)

or if used as part of an "if" switch...

 (h = ( navigator.appName == 'Microsoft Internet Explorer' ? true : false))