Why is FF on OS X loosing jQuery-UI in click event handler?

Posted by Jean-François Beauchamp on Stack Overflow See other posts from Stack Overflow or by Jean-François Beauchamp
Published on 2012-03-28T04:07:14Z Indexed on 2012/03/28 5:29 UTC
Read the original article Hit count: 209

Filed under:
|
|

In a web page using jQUery 1.7.1 and jQUery-UI 1.8.18, if I output $.ui in an alert box when the document is ready, I get [object Object]. However when using Firefox, if I output $.ui in a click event handler, I get 'undefined' as result. With other browsers (latest versions of IE, Chrome and Safari), the result is still [object Object] when clicking on the link.

Here is my HTML Page:

<!doctype html>
<html>
<head>
    <title></title>

    <script src="Scripts/jquery-1.7.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.8.18.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {

            alert($.ui);    // ALERT A

            $(document).on("click", ".dialogLink", function () {
                alert($.ui);    // ALERT B
                return false;
            });
        });
    </script>

</head>
<body>
    <a href="#" class="dialogLink">Click me!</a>
</body>
</html>

In this post, I reduced to its simplest form another problem I was having described here: $(this).dialog is not a function. I created a new post for the sake of clarity, since the real question is different from the original one now that pin-pointed where the problem resided.

UPDATE:

IF I replace my alerts with simply alert($); I get this result for alert A:

function (selector, context) {
    return new jQuery.fn.init(selector, context, rootjQuery);
}

and this one for alert B:

function (a, b) {
    return new d.fn.init(a, b, g);
}

This does not make sense to me, although I may not be understanding well enough what $ is...

UPDATE 2:

I can only reproduce this problem using Firefox on OS X. On Firefox running on Windows 7, everything is fine.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about osx