0

I have a scenario which is

Index.jsp, included a js file say temp.js, 10 data coming from backend as JSON and in jquery I am creating anchor tag with onclick property object = []

(for i=0;i<10;i++)
 object = new Object();
  //setting the different attributes of this object and passing index to the onclick function
 <a href="modal.jsp" onClick(i) ></a>

And Onclick is opening the bootstrap modal and in a bootstrap modal div.say #actionModal in Index.jsp and the body of modal is written in modal.jsp

modal.jsp contain a form which i have to fill after clicking of respective anchor tag generated in the index.jsp page and I have data associated with it.

Now If I want to fill all the form in modal.jsp I have to call this temp.js again then only jquery can fill elements of forms accessing Id.As It is loaded after the execution of erlier js file. But I don't want to do that. What is the best way to achieve this scenario.

I hope I made my doubt clear to everyone ;)

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Saurabh Sinha
  • 1,772
  • 4
  • 27
  • 54

1 Answers1

0

This has been answered a few times.

Use jquery on() function.

jQuery .on function for future elements, as .live is deprecated

http://api.jquery.com/on/

Community
  • 1
  • 1
crafter
  • 6,246
  • 1
  • 34
  • 46