On Nov 5, 2:58 am, jak0lantash <[EMAIL PROTECTED]> wrote:
> Hi everybody.
>
> I have some difficulties with bindAsEventListener. I'm working on a
> little module system (like in netvibes, but simpler).
> In the page, there are two div, kind of module, one on top, one on
> bottom. With a button, I switch the both div.
>
> 1) To switch, I use - and I think the problem is here - the property
> innerHTML
> 2) To listen the click event of the both buttons, I create two Object
> of a Class Module (created with the prototype lib Class.create), and I
> link the button to a function by bindAsEventListener.
> 3) My problem is : the switching works well, but after this action,
> the both buttons seem to not be linked anymore to the function.
> Nothing happen, the function is not called...

I think that your solution is way to complex for what you are doing.
If all you want to do is swap the position of the divs, insert the one
that you want to move down as the next sibling of the one below it (if
there is one) - i.e. the nextSibilng of its nextSibling.

e.g.

<script type="text/javascript">

function moveDown(el) {
  var div = el.parentNode;
  var nextSib = div.nextSibling;
  while (nextSib && nextSib.nodeType != 1) {
    nextSib = nextSib.nextSibling;
  }
  if (nextSib) {
    div.parentNode.insertBefore(div, nextSib.nextSibling);
  }
}

</script>


<div id="container">
 <div id="module-0">
  <button onclick="moveDown(this);">Move Down A</button>
 </div>

 <div id="module-1">
  <button onclick="moveDown(this);">Move Down B</button>
 </div>

 <div id="module-2">
  <button onclick="moveDown(this);">Move Down C</button>
 </div>
</div>


--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to