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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.