Re: [Proto-Scripty] Attach Ajax.Updater to link

2012-10-29 Thread donnek
On Sunday, 28 October 2012 22:06:35 UTC, Walter Lee Davis wrote:

 I use elm to stand for element, and evt to stand for event. It's just a 
 habit I have, to keep clear in my head what I am dealing with when I use an 
 observer or an iterator.

snip

 
I see - that seems like a very good habit for me to copy!

I prefer unobtrusive observers for several reasons. 

 First, they remove the masses of repeating inline code from the HTML,

snip

 Second, if your observer is all in one place, you can make sweeping 
 changes without having to go back and rewrite every invocation of the 
 method.

snip


Again, that makes a lot of sense, expecially now I've read over everything 
again this morning.

Thanks again for your help, Walter - I spent most of Friday on this, and 
wouldn't have worked it out on my own.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/Z62ZzORltGUJ.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Attach Ajax.Updater to link

2012-10-28 Thread donnek
I'm new to Prototype, and I'm trying to use AJAX to update divs inthe 
background, pulling data from a database.  I've got Ajax.Updater to work 
with the output of a form, but I'm having difficulty with adpting it for 
use with a link.  Basically, I have a list of words produced by the db, 
each of them a clickable link, and when I click on the word I want the 
context of the word (likewise drawn from the db) to come up in a div below 
the list.

What I have at the minute:

*calling page:*
diva href=javascript:void(0); class='textword' id='myword1' 
onclick=get_word()myword1/a/div
diva href=javascript:void(0); class='textword' id='myword2' 
onclick=get_word()myword2/a
div id=output[Results appear here.]/div
script
function get_word()
{
new Ajax.Updater
( 
'output', 
'mylist.php',
{
method: 'get',
parameters: { word: $(this).attr(id) }
}
);
}
/script
*
mylist.php:*
[db connection stuff]
$word=trim($_GET['word']);
$sql=query(select * from mytable where word~'$word';);
while ($row=pg_fetch_object($sql))
{
echo $context.br /;
}

Run by itself, mylist.php gives the results I want, so I think I haven't 
got the right invocation for the link, but after several hours searching 
and experimenting, I have to ask!

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/z616OxDuu6oJ.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Attach Ajax.Updater to link

2012-10-28 Thread donnek
On Sunday, 28 October 2012 15:53:37 UTC, Walter Lee Davis wrote:

 I'm pretty sure your problem is right here. There's no attr() method in 
 Prototype. Try readAttribute() instead, and you appear to have everything 
 right besides. 


Thanks, Walter, but unfortunately changing that line to:
parameters: { word: $(this).readAttribute(id) }
doesn't help.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/eL8tDmQMQUQJ.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Attach Ajax.Updater to link

2012-10-28 Thread donnek


On Sunday, 28 October 2012 15:53:37 UTC, Walter Lee Davis wrote: 
 What does Firebug say your request looks like? What does your server 
 respond with? 


TypeError: $(this).readAttribute is not a function

parameters: { word: $(this).readAttribute(id) }

There's no change to the calling page - it shows nothing in the output div.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/23HHumtY6uYJ.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Attach Ajax.Updater to link

2012-10-28 Thread donnek
On Sunday, 28 October 2012 20:32:34 UTC, Walter Lee Davis wrote:

 Okay, that means that 'this' inside the Ajax.Updater is not set to what 
 you think it is. Try this: 
 snip
 Much cleaner and fewer global variables are massacred. 


Hey, thanks!  Both of those work. But I don't understand what elm (not 
the tree, I assume!) and evt are/do.  And why is the second cleaner 
(because I find the first easier to understand).  Thanks again for taking 
the time on this.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/eGR_Yuma92gJ.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.