How to connect onchange in IE7 + to the parent element

I have a dynamic form where strings are added and removed using JavaScript. From Safari, Chrome and Firefox, the form works beautifully. In IE, let me just say that this is not ...

<div id="container">
  <div class="row">
    <input name="name[]">
    <select name="color[]">
      <option>Red</option>
      <option>Green</option>
      <option>Blue</option>
    </select>
  </div>
  <div class="row">
    <input name="name[]">
    <select name="color[]">
      <option>Red</option>
      <option>Green</option>
      <option>Blue</option>
    </select>
  </div>

  <a id="add-another" href="#">Add a row</a>
</div>

<script src="prototype.js"></script>
<script>
  $("container").observe("change", function(ev) {
    alert("changed " + ev.element() + " to " + $F(ev.element()));
  });

  $$("#container input, #container select").each(function(el) {
    el.observe("change", function(ev) {
      alert("changed[2] " + ev.element() + " to " + $F(ev.element()));
    });
  });

  $("add-another").observe("click", function(ev) {
    var cloned = $("container").down(".rule").clone(true);
    $("container").insert({top:cloned});
    ev.stop();
  });
</script>

The only exchange messages I see is this changed[2]. I would rather look change, as this would mean that I have only one listener, not hundreds.

Are there any known workarounds so that I can set one watcher in the parent node and receive onchange events?

I read the MSDN article on onchange and I found a comment saying that onchange cannot be attached, but maybe there is a solution there?

+3
1

, Safari, FF Chrome. , -, . Clever.

- , IE , , PeriodicalExecutor Abstract.TimedObserver , , IE .

0

All Articles