readyX

readyX
 点击下载

readyX extends the jQuery(document).ready event to permit greater control of the order in which the ready event callbacks get executed. readyX provides three queues instead of jQuery's one.
The queues are:

first : single function that runs as the very first callback

last : single function that runs as the very last callback

list : array of functions that are run sequentially between the first and last callbacks. callbacks in jQuery.readyList are appended to the end of the array for executing.

The sequence of actions that readyX takes are:

  1. The first call to readyX prepends a readyX callback to jQuery.readyList. Basically, the callback cuts to the beginning of the line.
  2. readyX has an independent list that is controlled by instructions provided when readyX is called. The available instructions are:
    • commands for first and last queues:
      • first : assigns a callback as the very first item to run. this callback is NOT part of the list controlled the commands below
      • last : assigns a callback as the very last item to run. this callback is NOT part of the list controlled the commands below
    • commands for list queue:
      • insert : inserts a callback at a specified position. if a callback is already present at that position, it is pushed back by one.
      • replace : replaces a callback with another at a specified position
      • delete : deletes a callback at a specified position
      • prepend : adds callback to the beginning of the readyX list
      • append : default action. adds callback to the end of the readyX list
  3. once the readyX callback is called by jQuery's ready handler, it fires the special callback first.
  4. items in the readyX list are executed.
  5. the special last callback is binded to the document and will run after jQuery readyList is complete.
  6. readyX's list and the special first/last are reset
  7. jQuery.ready runs through jQuery readyList.
  8. any bound ready event handlers are executed, including the last callback.

转载请注明:代码家园 » readyX

评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)