views:

364

answers:

1

I have an ajax link in my application:

<head>
<script type="text/javascript">function GoFurther() { ... }</script>
</head>
...
<%= Ajax.ActionLink("Go", "SomeAction", "SomeController", new AjaxOptions() { UpdateTargetId = "someDiv" }) %>
<div id="someDiv"></div>

I want to execute GoFurther() after ajax request completes AND someDiv is filled with its content so that it can bind some events on some buttons that've come from server. OnCompleted and OnSuccess seem to work after the ajax answer is received but before someDiv is filled. So they do not work for me.

To be clear, some div will be filled with some content after ajax call:

<someDiv><input type="button" value="Click" class="someButton" /></someDiv>

GoFurther makes some bindings using $(".someButton").click(...); so it must run once someDiv is completely filled. How can I make sure it runs after someDiv is filled?

A: 

OnSuccess is supposed to run after the DOM element has been updated [according to the source code for the Mvc Ajax Helpers - see OnComplete method]. Is there a particular problem that is occurring when you use OnSuccess?

anurse
Yes, OnSuccess="GoFurther" does not call GoFurther method.
Serhat Özgel
I was making a mistake. OnSuccess worked now.
Serhat Özgel