0

I have a parent jsp in which another jsp will be included. In the child jsp another jsp is included.

There will be a button in first child jsp, if we click that button ajax call will be triggered and this will append the div of second child jsp.

Problem here is:: In the appended second child jsp, Javascript is not working.

function abc(){
    $("[id^=<%=KunalBean.getBeanFieldPrefix()%>rdxCarterz]").on("click", function() {
    alert("after ajax call")
});
}

I am calling this abc function on success call of ajax. After ajax call, the function abc() is getting called, but the click event is not working. So when I click on the corresponding radio option, it does not work.

Please let me know what can be the solution for this problem.

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
The Dark Knight
  • 4,986
  • 10
  • 42
  • 86

1 Answers1

0

When trying to call event from a dynamically loaded object use this method

function abc(){
    $("body").on("click" , "[id^<%=KunalBean.getBeanFieldPrefix()%>rdxCarterz]",function({
     alert("after ajax call");
  });
}
sami
  • 49
  • 13
  • I have tried this way. It did not work.i cannot use $("body"),because i m including the same jsp at some other places in the application where ther e is no ajax call.it is affecting that palces also – The Dark Knight Jul 31 '14 at 13:19