Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#8799 closed bug (invalid)

document loading events ready through error!

Reported by: awakeel Owned by:
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:

Description

document loading events ready

like

$(

alert('test');

)

or

$.ready( alert('test');)

Through error, when i remove semi colon then its work fine. is it bug or user mistake. correct me if i am wrong?

Change History (4)

comment:1 Changed 9 years ago by ajpiano

Resolution: invalid
Status: newclosed

This is a user mistake. You have to pass a function reference to $(document).ready(), you are *executing* a window alert and passing its return value (nothing) to document ready as a handler. The correct syntax would be

$(function() {
 alert("test");
});

comment:2 Changed 9 years ago by awakeel

All three of the following syntaxes are equivalent:

$(document).ready(handler)
$().ready(handler) (this is not recommended)
$(handler)

The three format is supported so i am using the last one. did you checked that.

Last edited 9 years ago by awakeel (previous) (diff)

comment:3 Changed 9 years ago by ajpiano

A function reference is not the same as executing a function. http://fixingthesejquery.com/#slide32

comment:4 Changed 9 years ago by awakeel

Ok

Note: See TracTickets for help on using tickets.