[jQuery] Re: Retrieving information outside of $this

2007-04-21 Thread SiCo

Very interesting thanks both of you, I will have a play later. My back
up plan was to create an array of all the locations but I didn't want
to store too much data. My first draft of the code is messy enough as
it is calling the id's and name's from all the divs etc. There has to
be a better way. Thanks for the tips though, I wasn't sure how to use
paths and I never seem to have much luck with 'parent' but I guess you
have to call it more than once.

Thanks
Simon



[jQuery] Re: Retrieving information outside of $this

2007-04-20 Thread Andy Matthews

Ooops...

This gets the latitude value:
var lat =
$(this).parent().parent().children('.editable').children('span').attr('name'
,'longitude').html();

Change it up to get longitude 

-Original Message-
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of SiCo
Sent: Friday, April 20, 2007 12:55 PM
To: jQuery (English)
Subject: [jQuery] Retrieving information outside of $this


I have a small problem, probably more to do with me not knowing more than
anything else!!

My structure is like so:

div class=main loc rel=album name=17 h3Los Angeles/h3 div
class=data div class=editable name=17bLatitude:/b span
name=latitude34.052019404448785/spanbr / bLongitude:/b span
name=longitude-118.24318885803223/span
/div
p
img src=trip-goto.gif name=goto rel= width=16 height=16
border=0 alt=View this location on the map. title=View this location on
the map. / a href=img src=trip-remove.gif width=16 height=16
border=0 alt=Remove this album from the trip. title=Remove this album
from the trip. //a /p /div /div

Clicking on each of these blocks (multiple blocks per list) changes it to an
editor and you can select on aGoogle Map the location and it updates etc.

Now what I want is when the trip-goto.gif img is clicked I want the map to
scroll to the lat and long held in the span. What I can't work out is in the
click event how to grab the lat and long from the span tags... either
traversing the tree backwards etc or another way. I can't / don't want to
use id's as there can be 20 of these per page in ahierachical fashion so I'd
rather work with '$this'...

Any thoguhts? I am sur eit's easy...

Thanks
Simon




[jQuery] Re: Retrieving information outside of $this

2007-04-20 Thread Andy Matthews

Sorry for the loads of emails.

Using your exact code setup, this is what I came up with:
$('div.data a').click( function() {
var lat =
$(this).parent().parent().children('.editable').children('span').attr('name'
,'longitude').html();
alert(lat);
return false;
});


 

-Original Message-
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of SiCo
Sent: Friday, April 20, 2007 12:55 PM
To: jQuery (English)
Subject: [jQuery] Retrieving information outside of $this


I have a small problem, probably more to do with me not knowing more than
anything else!!

My structure is like so:

div class=main loc rel=album name=17 h3Los Angeles/h3 div
class=data div class=editable name=17bLatitude:/b span
name=latitude34.052019404448785/spanbr / bLongitude:/b span
name=longitude-118.24318885803223/span
/div
p
img src=trip-goto.gif name=goto rel= width=16 height=16
border=0 alt=View this location on the map. title=View this location on
the map. / a href=img src=trip-remove.gif width=16 height=16
border=0 alt=Remove this album from the trip. title=Remove this album
from the trip. //a /p /div /div

Clicking on each of these blocks (multiple blocks per list) changes it to an
editor and you can select on aGoogle Map the location and it updates etc.

Now what I want is when the trip-goto.gif img is clicked I want the map to
scroll to the lat and long held in the span. What I can't work out is in the
click event how to grab the lat and long from the span tags... either
traversing the tree backwards etc or another way. I can't / don't want to
use id's as there can be 20 of these per page in ahierachical fashion so I'd
rather work with '$this'...

Any thoguhts? I am sur eit's easy...

Thanks
Simon




[jQuery] Re: Retrieving information outside of $this

2007-04-20 Thread Roman Weich


Andy Matthews schrieb:

What?!?!?

You can use html based pathing in jQuery? Why didn't someone tell me that?!?

How come I get an error?


Sure I can! ;P

What kind of error?


[jQuery] Re: Retrieving information outside of $this

2007-04-20 Thread Andy Matthews

Ah...i see it. It was a syntax error. You had the closing }) after the
second alert and I missed it.

Works a treat. Freaking awesome!



 

-Original Message-
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Roman Weich
Sent: Friday, April 20, 2007 2:52 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Retrieving information outside of $this


Andy Matthews schrieb:
 What?!?!?
 
 You can use html based pathing in jQuery? Why didn't someone tell me
that?!?
 
 How come I get an error?
 
Sure I can! ;P

What kind of error?