1

The OnCompleteStuff is never called, what do I wrong?

    <script type="text/javascript">

        function OnBeginStuff() {
            $("#StuffPanel").fadeTo("slow", 0.50);
        }
        function OnCompleteStuff(request, status) { // Never called
            $("#StuffPanel").fadeTo("slow", 1.00);
        }

        $(document).ready(function () {

            $('.mainLink', $('#NavigationPanel')).click(function (e) {
                e.preventDefault();
                $.ajax({
                    url: $(this).attr('href'),
                    beforeSend: OnBeginStuff,
                    complete: OnCompleteStuff,
                    success: function (html) {
                        $('#StuffPanel').html(html);
                    }
                });
            });
        });
    </script>    
</head>
<body>
    <div id="NavigationPanel">
        @Html.ActionLink("1", "Index", "One", null, new { @class = "mainLink" })
        @Html.ActionLink("2", "Index", "Two", null, new { @class = "mainLink"  })
        @Html.ActionLink("3", "Index", "Three", null, new { @class = "mainLink" })    
    </div>
    <div id="StuffPanel">
        @RenderBody()
    </div>
</body>
</html>
msfanboy
  • 5,273
  • 13
  • 69
  • 120
  • Are you certain the `click` handler is working? –  Apr 30 '12 at 21:52
  • Have you tried putting a `console.log('done')` in the CompleteStuff function to verify that it's not being called? It could just be an issue with the animation queue. – Sam Dufel Apr 30 '12 at 22:00
  • Since I changed from Ajax.ActionLink to a Html.ActionLink and ajaxified it my animation stopped working correctly. Could that be the reason? see here my origin setup: http://stackoverflow.com/questions/10389740/rewrite-an-asp-net-mvc-ajax-actionlink-as-a-jquery-ajax-statement – msfanboy Apr 30 '12 at 22:01
  • sorry I do not understand this, but the 2nd function is called because "done" is output in console. I swear I put a breakpoint there in google chrome... ok needs then a new question because the animation seem to have threading problems see my comment above. We can close this question then. – msfanboy Apr 30 '12 at 22:13

0 Answers0