Bitcoin Forum
September 24, 2021, 03:13:56 PM *
News: Latest Bitcoin Core release: 22.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: jquery document.ready  (Read 973 times)
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
November 13, 2011, 09:10:25 AM
 #1

if these are 100% equivalent, why on earth would anyone ever use the longer version?

$(document).ready(handler)
$(handler)

i really wonder.

1632496436
Hero Member
*
Offline Offline

Posts: 1632496436

View Profile Personal Message (Offline)

Ignore
1632496436
Reply with quote  #2

1632496436
Report to moderator
1632496436
Hero Member
*
Offline Offline

Posts: 1632496436

View Profile Personal Message (Offline)

Ignore
1632496436
Reply with quote  #2

1632496436
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1632496436
Hero Member
*
Offline Offline

Posts: 1632496436

View Profile Personal Message (Offline)

Ignore
1632496436
Reply with quote  #2

1632496436
Report to moderator
1632496436
Hero Member
*
Offline Offline

Posts: 1632496436

View Profile Personal Message (Offline)

Ignore
1632496436
Reply with quote  #2

1632496436
Report to moderator
captainteemo
Full Member
***
Offline Offline

Activity: 143
Merit: 100


View Profile
November 15, 2011, 05:02:46 AM
 #2

one waits for the page to complete loading, then do actions in the background. if you put this at the top of a page, with a slow thing, it waits for the page to finish
other fires wherever it hits (blocking, non-async) if you put this at the top of a page, it won't finish rendering until it returns
btc_artist
Full Member
***
Offline Offline

Activity: 154
Merit: 100

Bitcoin!


View Profile WWW
November 15, 2011, 07:24:18 AM
 #3

if these are 100% equivalent, why on earth would anyone ever use the longer version?

$(document).ready(handler)
$(handler)

i really wonder.


As far as I know, nobody uses the longer version.  It *is* self-documenting though, which is a plus I guess.

BTC: 1CDCLDBHbAzHyYUkk1wYHPYmrtDZNhk8zf
LTC: LMS7SqZJnqzxo76iDSEua33WCyYZdjaQoE
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
November 15, 2011, 09:46:30 AM
 #4

one waits for the page to complete loading, then do actions in the background. if you put this at the top of a page, with a slow thing, it waits for the page to finish
other fires wherever it hits (blocking, non-async) if you put this at the top of a page, it won't finish rendering until it returns

no, they are functionally identical... both only fire when the 'document' is 'ready'... one is just a shorter way of writing it, but i've seen hundreds of examples all over the web that has the longer version in it.
btc_artist
Full Member
***
Offline Offline

Activity: 154
Merit: 100

Bitcoin!


View Profile WWW
November 15, 2011, 08:27:51 PM
 #5

So the answer to your question is probably that people just copy example they see (the long version) and are oblivious to the fact that there's a more concise way to do it.

BTC: 1CDCLDBHbAzHyYUkk1wYHPYmrtDZNhk8zf
LTC: LMS7SqZJnqzxo76iDSEua33WCyYZdjaQoE
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!