Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Running init() after delegate() causes an error

I'm using a Pro version, and spent a lot of time fighting this problem before I realized what's happening.

Seems that calling Tipped.init() after any Tipped.delegate() was called, causes
ReferenceError: selector is not defined.

Full example below. If I uncomment the undelegate() call, things work.

<head>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script type="text/javascript" src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
    <script type="text/javascript" src="assets/tipped/js/tipped/tipped.js"></script>
    <link rel="stylesheet" type="text/css" href="assets/tipped/css/tipped/tipped.css"/>

    <script type="text/javascript">
            $(document).ready(function() {
                Tipped.init();
                Tipped.delegate('.delegation-example', { skin: 'blue' });
//                Tipped.undelegate('.delegation-example');

                // Crashes if undelegate not called
                Tipped.init();
            });
    </script>
</head>

<body>
<span class='delegation-example' title="Created with event delegation">Delegation 1</span>
<span class='delegation-example' title="Another one">Delegation 2</span>
<span class='delegation-example' title="">Delegation 3</span>
<span class='delegation-example'>Delegation 4</span>
</body>
</html>
Sign In or Register to comment.