Hi!
I am pretty new to prototype/JS -- so there must be something really
basic I am missing.
(I want to do more intricate things with this but I just taking little
steps... )
So far what the code does it makes an ''ajax.request'' which
gets the
json data, then dumps that data to the screen .. then the user clicks
an item in the dumped json packet and an alert jumps up saying the
contents of the div tag that was clicked - instead it says ''object
htmldivelement'' ...
Just not sure what I am doing wrong, should''nt the alert give me the
text inside the div tag with the specified ID? ...
// part one of the script (top of the page)
function listEvents()
{
var url = ''/ajax/list_events.php'';
var pars = ''list_events=yes'';
new Ajax.Request(
url,
{
method: ''get'',
parameters: pars,
asynchronous: false,
onComplete: process
});
}
var data;
function process(rt)
{
data = rt.responseText.evalJSON();
}
// body of the page
Select events:
<div class="scroll" id="listEvents"></div>
<script>listEvents()
if(data)
{
for (var index = 0, len = data[''event_id''].length; index
< len; +
+index){
var item = data[''event_id''][index];
var name = data[''name''][index];
var start_date = data[''start_date''][index];
new Insertion.Bottom(''listEvents'', "\n<div
id=\""+ item +"\"
onclick=\"alert($(''"+item+"''))\">"+
name +"</div>");
}
}
</script>
// what the parsed document code looks like
<div class="scroll" id="listEvents">
<div id="b0312f144a117f787bdf519b2d6a3d7e" onclick="alert($
(''b0312f144a117f787bdf519b2d6a3d7e''))">TACTICAL
TIPSPRACTICAL PLAYS:
HOW TO SURVIVE IN A POST-SB899 WORLD - Ontario</div>
<div id="d96fe0ae5f00acae2bc84e32c82d9fff" onclick="alert($
(''d96fe0ae5f00acae2bc84e32c82d9fff''))">THE STATE BAR
OF CALIFORNIA
80th ANNUAL MEETING</div>
</div>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---