Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery BBQ generates error with jQuery 2

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?

like image 675
Lee Jenkins Avatar asked Oct 20 '22 10:10

Lee Jenkins


1 Answers

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 )

like image 158
samad montazeri Avatar answered Oct 23 '22 01:10

samad montazeri