Re: [Proto-Scripty] Event listeners on elements 'written over' by AJAX

2010-05-10 Thread Walter Lee Davis
What I prefer to do is to add a single persistent observer to an element that won't be destroyed during the life of the page, and then delegate listening to that element. So if I had a list of things that I wanted to observe, and one of the things I was doing was adding or deleting those li

[Proto-Scripty] Event listeners on elements 'written over' by AJAX

2010-05-10 Thread Junkshops
Hi all, I'm wondering what the appropriate thing to do is wrt event listeners on elements that get replaced by an Ajax.Updater call or something similar. It seems like a giant pain to have to run through all the sub elements of the container you're updating and remove all the listeners for every p

[Proto-Scripty] Re: readAttribute problem

2010-05-10 Thread T.J. Crowder
Hi, As Walter and Yaz pointed out, you're trying to grab the text content of the element, rather than an attribute of it. See this thread for a discussion of how to do that, and an implementation of a function to do it: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/1

[Proto-Scripty] Re: Javascript Prototype Best Practice Event Handlers

2010-05-10 Thread T.J. Crowder
Hi, If you really want to watch each individual `li` directly, then what you have seems perfectly straightforward. But in that situation, barring a really good reason to do it that way, I wouldn't use a handler on each `li`; I'd listen for clicks on the elementToUpdate (or the `ul` within it) inst

[Proto-Scripty] Javascript Prototype Best Practice Event Handlers

2010-05-10 Thread ncubica
Hi this question is more a consulting of best practice, Sometimes when I'm building a complete ajax application I usually add elements dynamically for example. When you'r adding a list of items, I do something like: var template = new Template("#{value}"); var arrayTemplate = []; arrayOfItem.each(

[Proto-Scripty] Re: readAttribute problem

2010-05-10 Thread Pranav
I usually add a method to the Element to do this:- Element.addMethods({ getText: function(element){ element = $(element); return element.textContent || element.innerText || _readTextNodes(element); function _readTextNodes(e){ if(e.nodeType == 3 || e.nodeType == 4){

Re: [Proto-Scripty] Re: readAttribute problem

2010-05-10 Thread Alex McAuley
what about innerText() || textContent(); ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: "Yaz" To: "Prototype & script.aculo.us" Sent: Monday, May 10, 2010 4:13 PM Subject: [Proto-Scripty] Re: readAttribute problem I can't believe something so simple would

Re: [Proto-Scripty] Binding functions to $$ directly

2010-05-10 Thread Alex McAuley
Jquery also references "this" inside the function as the object / element clicked.. Alex Mcauley http://www.thevacancymarket.com - Original Message - From: "Walter Lee Davis" To: Sent: Monday, May 10, 2010 3:55 PM Subject: Re: [Proto-Scripty] Binding functions to $$ directly jQuer

[Proto-Scripty] Re: readAttribute problem

2010-05-10 Thread Yaz
I can't believe something so simple would be so... unintuitive. Walter you're right. And I'm an idiot. :) -yaz On May 10, 11:10 am, Walter Lee Davis wrote: > Okay. $('tag').innerHTML.stripTags() will get you the inner text of   > the A tag in most browsers. Not sure if it's completely available

Re: [Proto-Scripty] Re: readAttribute problem

2010-05-10 Thread Walter Lee Davis
Okay. $('tag').innerHTML.stripTags() will get you the inner text of the A tag in most browsers. Not sure if it's completely available on every browser supported by Prototype, but it should be fairly consistent. Walter On May 10, 2010, at 11:01 AM, Walter Lee Davis wrote: $F is only for fo

Re: [Proto-Scripty] Re: readAttribute problem

2010-05-10 Thread Walter Lee Davis
Gaaa, never mind, that gets you the HREF. Walter On May 10, 2010, at 11:01 AM, Walter Lee Davis wrote: $F is only for form elements. You can't use it on an A or another non-form text container, as the OP would like. You could try maybe tag.toString().stripTags() to get the inner text in a c

Re: [Proto-Scripty] Re: readAttribute problem

2010-05-10 Thread Walter Lee Davis
$F is only for form elements. You can't use it on an A or another non- form text container, as the OP would like. You could try maybe tag.toString().stripTags() to get the inner text in a cross-browser manner. Walter On May 10, 2010, at 10:54 AM, Yaz wrote: You are trying to get the value

Re: [Proto-Scripty] Binding functions to $$ directly

2010-05-10 Thread Walter Lee Davis
jQuery conflates the meaning of $ and $$ in a useful manner, but Prototype provides the invoke function to shortcut what you are doing here. $$('#div1 p span.someclassName').invoke('observe','click', function(el) { alert('b'); }); To my mind, it's a little less magic and a lot more intent

[Proto-Scripty] Re: readAttribute problem

2010-05-10 Thread Yaz
You are trying to get the value of that tag, not an attribute. To do that, use these: $('tag'),getValue(); Or its shortcut: $F('tag'); http://api.prototypejs.org/dom/form/element/getvalue/ -yaz On May 10, 6:40 am, vtsuper wrote: > Dear sir, > > the following is the offical example of read

RE: [Proto-Scripty] Binding functions to $$ directly

2010-05-10 Thread Jonathan Rosenberg
How 'bout $$('#div1 p span.someclassName').invoke('observe', 'click', function(el) Close enough? -- Jonathan Rosenberg Founder & Executive Director, Tabby's Place http://www.tabbysplace.org/ -Original Message- From: prototype-scriptaculous@googlegroups.com [mailto:prototype-sc

[Proto-Scripty] Binding functions to $$ directly

2010-05-10 Thread Phonethics
How come I got to this $$('#div1 p span.someclassName').each(function(el) { Event.observe(el, 'click', function(event) { alert('a'); }); }); instead of something like this ? $$('#div1 p span.someclassName').observe('click', function(el) { alert('b'); }); Any way to get t

[Proto-Scripty] readAttribute problem

2010-05-10 Thread vtsuper
Dear sir, the following is the offical example of read attribute. But would you tell me how to make it return the text 'Prototype'? Prototype $('tag').readAttribute('href'); // -> '/tags/prototype' $('tag').readAttribute('title'); // -> 'view related bookmarks.' $('tag').readAttribute('my_widget

[Proto-Scripty] Prototype 1.5.0 backward compatible with 1.4.0?

2010-05-10 Thread p...@google
Hello, I have inherited an old application that uses Prototype v1.4.0 and Scriptaculous v1.5.3. I wanted to update: *Prototype from v1.4.0 to v1.5.0 (used by TafelTree v1.9.1) *Scriptaculous from v1.5.3 to v1.7.0 (used by TafelTree v1.9.1) The Scriptaculous CHANGELOG lists changes but does not se