IE9 Problem: dynamically created (via innerHTML) buttons and checkboxes do not work

I am working on a project that requires me to be able to grab html from a page and paste it into the main web page. It fully works in Chrome and Firefox, but it does not work in IE 9. Here is a cutout from the code that I use.

   if (!element.data('cache')) {

       $('#contentHolder').html('<img src="ajax_preloader.gif" width="64" height="64" class="preloader" />');

      $.get(element.data('page'), function (msg) {
         $('#contentHolder').html(msg);

         /* After page was received, add it to the cache for the current hyperlink: */
            element.data('cache', msg);
            setTimeout("checkonbox()", 100);
        });
    }
    else {
         $('#contentHolder').html(element.data('cache'));
        setTimeout("checkonbox()", 100);
    }

HTML entered

<table style="width:400px; height: 388px; text-align: left;" align="left">
<tr>
<td><input id="Checkbox0" type="checkbox"  onclick="changebuttons();" checked="true">  
Exclusive.</input></td>
</tr>
</table>

Plus a few extra buttons.

Everything looks great, but I can’t click on the checkbox or option buttons.

+5
source share
4 answers

I do not see the complete code in your question. But I assume that you did not enter the code inside the initializer:

    $(function () {
      // your jQuery code here.
    });

This will help the browser to trigger events related to its elements. Try this and see if there are any changes.

, - javascript. . javascript, - , FireBug, firefox.

0

, . , , , , , IE , .

, , "". , , , - :

<label for="Checkbox0"><input id="Checkbox0" type="checkbox"  onclick="changebuttons();" checked="true" />Exclusive.</label>

.

0

, dom, , . AJAX .

:

$.get(element.data('page'), function (msg) {
         $('#contentHolder').html(msg);

         //this will bind your input field  via javascript
         $('input#Checkbox0').click(changebuttons);

         /* After page was received, add it to the cache for the current hyperlink: */
            element.data('cache', msg);
            setTimeout("checkonbox()", 100);
});
0

element  

$(element)  

.

0

All Articles