[jQuery] Re: simple click event won't fire

2009-01-20 Thread mmvdl

Thx for pointing that out, native events won't fire...check!

I got carried away thinking the native event was firing because when i
initialy used

$(table.vacatures tbody tr).click( function(){
   $(this).find(a:first).click();
});

I got a 'too much recursion' error, thinking that the native event
fired - bubling back up to the tr  and firing over and over again.
That's why I tried .one().

Anyway, thx.


[jQuery] Re: simple click event won't fire

2009-01-19 Thread Joe

What is a one event?

On Jan 19, 6:48 am, mmvdl mm...@yahoo.co.uk wrote:
 Within a table each first td of every row has an a tag.
 But I want the whole tr to be clickable.

 To avoid recursion I've put a .one() event on the tr like so:

 $(table.vacatures tbody tr).one(click, function(){
    $(this).find(a:first).click();

 });

 But the click on the a tag will not fire. Why?


[jQuery] Re: simple click event won't fire

2009-01-19 Thread Ricardo Tomasi

It's a helper method that only fires once, then is removed.

http://docs.jquery.com/Events/one#typedatafn

mmvdl, if you are expecting that your click() call will trigger the
default browser action (following the link), that won't happen. click
() only fires the listeners, not the native behaviour. In this case
you can fake it with this:

$(table.vacatures tbody tr).click(function(){
   window.location = $(this).find(a:first)[0].href;
});

(no need for one() as you're leaving the current page anyway)

On Jan 19, 4:13 pm, Joe joseph.is...@gmail.com wrote:
 What is a one event?

 On Jan 19, 6:48 am, mmvdl mm...@yahoo.co.uk wrote:

  Within a table each first td of every row has an a tag.
  But I want the whole tr to be clickable.

  To avoid recursion I've put a .one() event on the tr like so:

  $(table.vacatures tbody tr).one(click, function(){
     $(this).find(a:first).click();

  });

  But the click on the a tag will not fire. Why?


[jQuery] Re: Simple click event

2008-09-04 Thread byron

That worked well. Thank you.

So in pseudocode this essentially says..

when document is ready:
bind the event 'click' to '#thelink'
invoke the href when a 'click' occurs

trigger a 'click'

correct? This is more for my own understanding.


[jQuery] Re: Simple click event

2008-09-04 Thread Karl Swedberg

yep. you got it. :)

--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Sep 4, 2008, at 8:46 AM, byron wrote:



That worked well. Thank you.

So in pseudocode this essentially says..

when document is ready:
   bind the event 'click' to '#thelink'
   invoke the href when a 'click' occurs

   trigger a 'click'

correct? This is more for my own understanding.




[jQuery] Re: Simple click event

2008-09-04 Thread byron

cool. thanks.

On Sep 4, 3:03 pm, Karl Swedberg [EMAIL PROTECTED] wrote:
 yep. you got it. :)

 --Karl

 
 Karl Swedbergwww.englishrules.comwww.learningjquery.com

 On Sep 4, 2008, at 8:46 AM, byron wrote:



  That worked well. Thank you.

  So in pseudocode this essentially says..

  when document is ready:
     bind the event 'click' to '#thelink'
     invoke the href when a 'click' occurs

     trigger a 'click'

  correct? This is more for my own understanding.


[jQuery] Re: Simple click event

2008-09-03 Thread Karl Swedberg
You can't trigger a link's default action with jQuery, but you can do  
something like this:


$().ready(function() {
  $('#thelink').bind('click', function() {
window.location = this.href;
return false;
  }).trigger('click');
});


--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Sep 3, 2008, at 10:41 AM, byron wrote:



I created an email link, that I want invoked (clicked) on page load.
I thought I could simply do:

$().ready(function() {
   $(#thelink).click()
})

Do I need to do something else?

Thanks.