[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

[jQuery] Re: JQuery Events

2009-02-24 Thread James
Try putting the bulk of your code in a separate function: $(function() { // do check on document ready myFunction(); // make click work $('#Professor').click(myFunction); }); function myFunction() { if ( $('#Professor').get(0).checked ) { $('#ProfessorField').show();

[jQuery] Re: JQuery events + ajax question

2008-12-09 Thread Beres Botond
Cleaning that up is not Jquery's job as far as I know but the JScript garbage collector (which basically depends on the browser). The garbage collector is pretty smart so it shouldn't be any leak... serious leaks used to happen only on Circular References especially in IE6 for example, but even th

[jQuery] Re: jQuery events don't work after AJAX load

2008-07-08 Thread [EMAIL PROTECTED]
Thanks Chris and Hamish! I ended up using the awesome LiveQuery plugin. On Jul 7, 7:08 pm, "Chris Bailey" <[EMAIL PROTECTED]> wrote: > Are you using the Livequery plugin to bind your events?  If not, then the > event binding, that presumably is setup in some other source file (other > than the

[jQuery] Re: jQuery events don't work after AJAX load

2008-07-07 Thread Chris Bailey
Are you using the Livequery plugin to bind your events? If not, then the event binding, that presumably is setup in some other source file (other than the HTML that's coming in via your load), won't even run against the new code from the AJAX load. Using Livequery will let you keep the code separ

[jQuery] Re: jQuery events don't work after AJAX load

2008-07-07 Thread Hamish Campbell
Possibly one of the most frequently asked questions: http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_request.3F On Jul 8, 1:54 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi folks, > > I have a page with a photo on it.  I load the comments f

[jQuery] Re: jQuery events on plain old JavaScript objects

2008-04-07 Thread Thom
I want a unified way of raising/handling events in my JavaScript codebase. As I'm already using jQuery, it'd be nice to reuse its smarts. :) On Apr 2, 5:35 pm, chrismarx <[EMAIL PROTECTED]> wrote: > interesting, for what purpose would you use this functionality? > why not just > > var monkey = {n

[jQuery] Re: jQuery events on plain old JavaScript objects

2008-04-02 Thread Ariel Flesler
I'd not rely on anything that is not in the docs. I suffered from these changes in the past. If you want a safe way to use this, you should check: jQuery.Collection: http://flesler.blogspot.com/2008/01/jquerycollection.html You just need to import the methods bind, unbind and trigger, and that ca

[jQuery] Re: jQuery events on plain old JavaScript objects

2008-04-02 Thread chrismarx
interesting, for what purpose would you use this functionality? why not just var monkey = {name:'Dave', climb:function(){alert(this.name + 'is climbing');} monkey.climb(); On Apr 2, 8:02 am, Thom <[EMAIL PROTECTED]> wrote: > This works: > > var monkey = { name: 'Dave' } > $(