Hi,

I'm rewriting some old code to use jQuery now, and I can figure out
why this isn't working and would love some help.  I used to create a
checkbox DOM element and assign a function object to the onlick
handler:

         var theElement = document.createElement( 'input' );
         theElement.type = "checkbox";
         theElement.onclick = checkCallback;

Then later I want to invoke that handler if some state is true, put
that in using jQuery a while ago:

        $(theRow).find(':input[type="checkbox"]').click();

When I did this the onclick handler was called and set up some
presentation based on the checkbox being 'checked'.  In the handler
the value of event.target.checked was true.  When the handler
finished, the UI presentation was a checked box.

Well, now I'm changing the HTML around so much that I'm rewriting it
with jQuery methods.  So now I create the checkbox (and its enclosing
table cell) with an HTML string:

   $row.append( $('<td class="'+ className +'" align="middle">'
         +'<input type="checkbox" name="iScsiTargetVolume" id="' foo'"/
>'
      +'</td>') );

And later set the onclick handler and TRY to check the box:
   $row.find(':checkbox').click( checkCallback );
   if ( test )
   {
      $row.find(':checkbox').click();
   }

However, in the click handler when I get the event.target.checked is
ALWAYS false for the above call.  All is as expected when the handler
is called based on a real UI click.  I've been playing with this for a
couple of hours and can't figure out what is up.

Thoughts anyone?

thanks,
Chuck

Reply via email to