Bug Tracker

Modify

Ticket #8799 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

document loading events ready through error!

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

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

comment:1 Changed 2 years ago by ajpiano

  • Status changed from new to closed
  • Resolution set to invalid

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 2 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.

Version 0, edited 2 years ago by awakeel (next)

comment:3 Changed 2 years ago by ajpiano

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

comment:4 Changed 2 years ago by awakeel

Ok

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.