[Prototype-core] Event.observe(window, 'load'.. issue not fixed!
Event.observe(window, 'load', function () { alert('1'); }); Event.observe(window, 'load', function () { alert('2'); }); Firefox, opera alerts 1 then 2, IE alerts 2 THEN 1!! Order is reversed and developeres are puzzled! Why isn't this issue still fixed?! -- You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en To unsubscribe, reply using remove me as the subject.
[Prototype-core] Event.observe problem
I'm using prototype 1.5 I want to click once and update text in two div parts. But I find out when I click the first time, nothing happened; when I click the second time, both div changed. why is that? How can I click only once, change both of these divs. Thank you in advance Yuncong !-- code begins -- script language=javascript src=prototype.js/script div id=qwer change this /div div id=zxcv also change this /div a id=asdf onclick=new Event.observe('asdf', 'click', function(){ new Ajax.Updater ( 'qwer', 'event1.html', { asynchronous: true, method: 'get' } ); new Ajax.Updater ( 'zxcv', 'event2.html', { asynchronous: true, method: 'get' } ); }); event.returnvalue=false; return false; href=event.html test /a --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Event.observe to pass additional arguments to callback
I've been playing with the Event.observe function as i need it to pass extra arguments to my callback function and keeping 'this' in the scope of the callback function Object. I don't know if theres a better way to do this but thought i would share it here. observe: function(){ var args = $A(arguments), el = $(args.shift()), evt = args.shift(), func = args.shift(); if(!func) return; if(el.addEventListener){ el.addEventListener(evt, func.bind.apply(func, [func].concat(args)), false); }else if(el.attachEvent){ el.attachEvent('on'+evt, func.bind.apply(func, [func].concat(args)) ); } } I can now do this : Event.observe('myElement', 'click', callBackFunc, extraArg1, extraArg2.); callBackFunc now recieves Arguments[0] = MouseEvent, [1] =extraArg1, [2] =extraArg2 and 'this' is a reference to callBackFunc and therefore any of its properties etc. It still allows you to set the Scope of 'this' : Event.observe('myElement', 'click', callBackFunc.bind('anyObj'), extraArg1, extraArg2); or Event.observe('myElement', 'click', callBackFunc.bind('anyObj', extraArg1, extraArg2) ); Any thoughts?? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@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-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Event.observe
Hi there, Events can be attached multiple times to the same element.. is there a way to prevent this? Something like ... if(!$(el).hasEventAttached()) Event.observe($(el), 'click', function()); ... would be great Any way to achieve this? Roland, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@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-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Event.observe will destroy the scope of Javascript OOP?
I discovered a funny pheno, which I don't know anyone else has stated this before. Say I define a class: function Cat(){ this.color = yellow; } Cat.prototype.showColor = function(){ alert(this.color) } Cat.prototype.init(){ Event.observe(button, click, this.showColor); } Now if i do elsewhere, var cat = new Cat(); Cat.init(); then you click on button, and you will see the color is undefined (instead of showing yellow); the observation of events seemed to make the function lost it's scope. I have a way to work around this but I would like to listen to what the developers may think. Thanks! Prototype is a great package and I love it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@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-core?hl=en -~--~~~~--~~--~--~---