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 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 : http://www.letroquet.eu/tests/module_inverse.html I hope somebody could help me. Thank you. Best regards. <script> 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 = this.buttonDownClick.bindAsEventListener(this); }, 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; $('module-'+another_module).innerHTML = html0; } } </script> <div id="module-0"> <img id="module-0-down" title="Move down" src="fleche_bas_mini.gif" / > </div> <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" / > </div> <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 [email protected] 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 -~----------~----~----~----~------~----~------~--~---
