Skip to main content

Bug Tracker

Side navigation

#11560 closed enhancement (plugin)

Opened April 05, 2012 09:27PM UTC

Closed April 06, 2012 03:28AM UTC

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

Attachments (0)
Change History (1)

Changed April 06, 2012 03:28AM UTC by dmethvin comment:1

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.