Bug Tracker

Opened 11 years ago

Closed 11 years ago

#11560 closed enhancement (plugin)

.ready() should not ignore the selector

Reported by: john.firebaugh Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:


Currently, $(<selector>).ready() ignores the selector and acts as though document was passed. I suggest that it instead act like other event binding functions, and call the callback with this bound to each matching element, or not at all if no elements match.

In particular, this would be convenient for including page-specific actions in a site's bundled assets. Assuming that a page was uniquely identified, for example with an id at the body element, page specific code could be isolated:

// index.js
$("#index").ready(function () {
  // page specific code for index page

// post.js
$("#post").ready(function () {
  // page specific code for post page

Now index.js and post.js can be concatenated and minified, and the resulting bundle downloaded only once, and still each page will run only the correct initialization code.

Change History (1)

comment:1 Changed 11 years ago by dmethvin

Resolution: plugin
Status: newclosed

Sorry, nope. We're not going to mess with those semantics, it would no doubt break code. You could easily write a plugin to do it though.

Note: See TracTickets for help on using tickets.