Jump to content

Ajax Annoyance


glenelkins

Recommended Posts

Hi

 

I will explain this the best i can.

 

I am using jQuery in a quite complex application. The part i am stuck on grabs information from a database table with ajax and creates html output. Then assigns the output to an element with innerHTML. The output html contains checkboxes with unique IDs. I wanted these checkboxes to allow a click event, so I created javascript code into a string and also placed this into the document to allow the events be be trapped because when assigning code to an element with Javascript it actually does not really exist.

 

The problem im facing is not the checkbox click even, it picks that up fine, the problem is when I want to use innerHTML after the event is trapped onto one of the generated elements...make sense?

 

So I may have the following code for example (minus ajax):

 

<script type="text/javascript">

   // the line below is to trap the checkbox click event and place the date in the <span>
   // the date does NOT get placed!
    html = '<script type="text/javascript">$("#test").click ( function() { $("#date").innerHTML ( "14/11/2009" ); } );</script>';
    html += '<input type="checkbox" id="test" /> <span class="date" id="date"></span>';

   // the next line works fine, shows the checkbox
   $('#elementname').innerHTML ( html );
</script>

 

 

Link to comment
https://forums.phpfreaks.com/topic/189140-ajax-annoyance/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.