[Proto-Scripty] Passing Variables to Functions in addEventListener Within a Class

2010-07-23 Thread Doc Torbin
I am working on a class now and part of the initialization is adding event listeners to an object. I'd like to pass some value through to the functions that are attributes of the class but I can't seem to figure it out. Here's a sample piece of the code: var MyClass= new Class.create();

[Proto-Scripty] passing data with update

2010-07-23 Thread ChrisH
I am trying to get a short list of supervisors into a form based on a selection off_name in an Autocompleter, also in that form. The code below worked until I added the getOfficerData() function, passing an index value returned in the li as li.id. I started getting update not defined errors in

[Proto-Scripty] Re: Passing Variables to Functions in addEventListener Within a Class

2010-07-23 Thread T.J. Crowder
Hi, Since you're creating the event handler inside your `initialize` function, you can take advantage of the fact it's already a closure by assigning `this` to a local variable (`self` is a common name for it) and then using `self` within the closure (the event handler), since it will inherit it.

[Proto-Scripty] Re: passing data with update

2010-07-23 Thread T.J. Crowder
Hi, `update` isn't a global symbol, you either need `Element.update` or an element instance on which you call `.update`, e.g.: var id = foo; Element.update(id, pHi there/p); // -or- $(id).update(pHi there/p); (In the latter case, it doesn't have to be looked up by ID, as long

[Proto-Scripty] Re: passing data with update

2010-07-23 Thread ChrisH
The second form $(id).update(pHi there/p); seems most appropriate, but my element is a form field, oid of the element $ ('eventform'). Firebug shows me that it hasn't processed an update because it sends my default value of $('eventform').oid to the server. So I think the $(id) part is the

[Proto-Scripty] Re: Passing Variables to Functions in addEventListener Within a Class

2010-07-23 Thread Matt Foster
You can just add parameters to the bind call and they will show up in execution. $(id).observe('mousedown', this.myFunction.bind(this, otherParam); Then I believe it shows up after the event. function myFunction(event, param){... but in your case, simply binding to this will allow you to

[Proto-Scripty] Re: Ajax abort method

2010-07-23 Thread Matt Foster
I did something similar in that I just patched Ajax.Request with some extra functionality to allow timeouts, I never fussed with it further than fundamental tests but it certainly worked. Take a peak and maybe you can learn how to write something to meet your own needs

[Proto-Scripty] Re: How do I remove and stash an observer?

2010-07-23 Thread Matt Foster
just store the reference to the listener and re-attach it to the element after the user has successfully purchased more comment tokens or whatnot. var myListener = function(){}; $(button).stopObserving(); //.. user buys tokens... $(button).observe('click', myListener); --