[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread olsch01
Glad you found your own solution so fast, Blake! If you want to slide the info divs up and down using the same link, you could also use the nice toogle function. Then you just have to do something like this: $(".peekaboo").each( function() { $(this).click( function() { va

[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread Blake Senftner
First off, I'd like to sincerely thank both olsch01 and charlie for their help, as well as the superb website of list member Karl Swedberg. Between their help and that web site, I have a completely generalized solution I am very happy with! It was Karl's www.learningjquery.com site, and h

[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread olsch01
Agreed :)

[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread Charlie
good point, if links are sortable would need to re think my method. Assumed they were in order in my example. If they are in order however there is less searching of the DOM required, especially if there are hundreds or thousands of tags olsch01 wrote: Hi Charlie, one drawback of your fu

[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread olsch01
Hi Charlie, one drawback of your function that I see is, that it only works if the divs with the data to reveal have a simple ID count and appear in sorted order in the code (i.e. dataToReveal1, dataToReveal2, dataToReveal3 etc.). If you mix them up, or if you have more complex IDs (for whatever

[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread olsch01
Hi Charlie, one drawback of your function that I see is, that it only works if the divs with the data to reveal appear in sorted order in the code (i.e. dataToReveal1, dataToReveal2, dataToReveal3 etc.). If you mix them up, the function doesn't work properly anymore (at least not in my test), sin

[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread Charlie
Cleaner if you can use a class on the links. Assume they now have class "dataReveal". i=1; $(".dataReveal").each(function () {     var actOnElem = "#dataToReveal" +i;        $(this).click( function() {             $(actOnElem).slideDown();               return false;

[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread olsch01
OK, I guess this is one possible solution: $('a[id^=dataRevealLink]').each(function(){ var eventElemId = $(this).attr('id'); var eventElemIdNo = eventElemId.substring(14, eventElemId.length); var actOnElem = $('#dataToReveal' +eventElemIdNo);

[jQuery] Re: JQuery events and a possible scoping error on my part?

2009-07-04 Thread olsch01
Hi, I'm not a JS/jQuery expert, so as a quick test I added alert (actOnElem); inside your $(eventElem).click( function(), and the result always was #dataToReveal12. As mentioned, I am not an expert and still learning myself, but I think on dom ready the loop simply starts running until i equals