views:

24

answers:

1

I'm using dojo.create to throw some native widgets onto a page. In particular, I have put a set of radio buttons onto the page, and whether they function properly depends on where I put them.

I want to put them into a DIV I create. However, when I do that, they don't work. If I put them at the bottom of the body, they work. If I put them in the same DIV as another set of radio buttons I created earlier (I created that DIV, as well), they work. If I put the new DIV, with the buttons inside it, into the DIV where they worked, or at the bottom of the page, they don't work.

By "don't work", I mean that I connect to their onclick, but my connected function is not called. In Firefox, the radio group behavior is otherwise normal: I can select any one of the buttons in the group. In IE 8, I cannot change which item is selected.

Is this behavior that anyone recognizes?

A: 

"You'll figure it out yourself as soon as you ask for help." Happens to me a lot.

It turns out, in this case, that the problem was my adjusting the innerHTML (just inserting some text) of the div that I was putting the radio buttons in. I don't know why that was a problem, but don't do that! Instead of operating on the innerHTML, I created a couple of spans and assigned to their innerHTML. That was not a problem.

Roy J
Adjusting the innerHTML destroys the corresponding DOM subtree and recreates it. This is gonna void your event listeners and will cause some trouble if you still have references to the previously existing DOM elements
Pumbaa80