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
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 guess that switching the both innerHTML deconstruct the objects, and
then construct another instance of them, not linked...

For more understanding, I created a simply version in this page :

I hope somebody could help me.
Thank you.

Best regards.

var Module_surv = Class.create();
Module_surv.prototype = {
  initialize: function (module_id) {
    this.module_id = module_id;
    this.button_down = $('module-'+this.module_id+'-down');
    this.button_down.onclick =
  buttonDownClick: function (evt) {
    // Ajax request [ ... ]
    another_module = (this.module_id == 0) ? 1 : 0;
    html0 = $('module-'+this.module_id).innerHTML;
    $('module-'+this.module_id).innerHTML = $
    $('module-'+another_module).innerHTML = html0;

<div id="module-0">
  <img id="module-0-down" title="Move down" src="fleche_bas_mini.gif" /
<script>module_0 = new Module_surv('0');</script>

<div id="module-1">
  <img id="module-1-down" title="Move down" src="fleche_bas_mini.gif" /
<script>module_1 = new Module_surv('1');</script>

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 

Reply via email to