connected
(the connection is up and
running), connecting
(disconnected and trying to open a
new connection), and waiting
(failed to connect and
waiting to try to reconnect).retryTime - (new Date()).getTime()
. This key will
be set only when status
is waiting
.
There are " + highScoring.count() + " posts with " + "scores greater than 10
"; }); document.body.appendChild(frag); Unlike the other functions, `count` registers a dependency only on the number of matching documents. (Updates that just change or reorder the documents in the result set will not trigger a recomputation.) {{> api_box cursor_rewind}} The `forEach`, `map`, or `fetch` methods can only be called once on a cursor. To access the data in a cursor more than once, use `rewind` to reset the cursor. {{> api_box cursor_observe}} Establishes a *live query* that notifies callbacks on any change to the query result. `callbacks` may have the following functions as properties:We've always been at war with " + Session.get("enemy") + "
"; }); // Page will say "We've always been at war with Eastasia" document.body.append(frag); // Page will change to say "We've always been at war with Eurasia" Session.set("enemy", "Eurasia"); {{> api_box equals}} These two expressions do the same thing: (1) Session.get("key") === value (2) Session.equals("key", value) ... but the second one is always better. It triggers fewer invalidations (template redraws), making your program more efficient. Example: {{dstache}}! Show a dynamically updating list of items. Let the user click on an item to select it. The selected item is given a CSS class so it can be rendered differently. }} {{dstache}}#each posts}} {{dstache}}> postItem }} {{dstache}}/each}} {{! }}template>There are " + Users.find({online: true}).count() + " users online.
"; }); document.body.appendChild(frag); // Find all users that have been idle for a while, and mark them as // offline. The count on the screen will automatically update. Users.update({idleTime: {$gt: 30}}, {online: false}); {{> api_box renderList}} Creates a `DocumentFragment` that automatically updates as the results of a database query change. Most Meteor apps use `{{dstache}}#each}}` in a template instead of calling this directly. `renderList` is more efficient than using `Meteor.render` to render HTML for a list of documents. For example, if a new document is created in the database that matches the query, a new item will be rendered and inserted at the appropriate place in the DOM without re-rendering the other elements. Similarly, if a document changes position in a sorted query, the DOM nodes will simply be moved and not re-rendered. `docFunc` is called as needed to generate HTML for each document. If you provide `elseFunc`, then whenever the query returns no results, it will be called to render alternate content. You might use this to show a message like "No records match your query." Each call to `docFunc` or `elseFunc` is run in its own reactive context so that if it has other external data dependencies, it will be individually re-run when the data changes. Example: // List the titles of all of the posts that have the tag // "frontpage". Keep the list updated as new posts are made, as tags // change, etc. Display the selected post differently. var frag = Meteor.renderList( Posts.find({tags: "frontpage"}), function(post) { var style = Session.equals("selectedId", post._id) ? "selected" : ""; // A real app would need to quote/sanitize post.name return 'click
"}}
Mouse click on any element, including a link, button, form control, or div.
Use `preventDefault()` to prevent a clicked link from being followed.
Some ways of activating an element from the keyboard also fire `click`.
{{/dtdd}}
{{#dtdd "dblclick
"}}
Double-click.
{{/dtdd}}
{{#dtdd "focus, blur
"}}
A text input field or other form control gains or loses focus. You
can make any element focusable by giving it a `tabindex` property.
Browsers differ on whether links, checkboxes, and radio buttons are
natively focusable. These events do not bubble.
{{/dtdd}}
{{#dtdd "change
"}}
A checkbox or radio button changes state. For text fields, use
`blur` or key events to respond to changes.
{{/dtdd}}
{{#dtdd "mouseenter, mouseleave
"}} The pointer enters or
leaves the bounds of an element. These events do not bubble.
{{/dtdd}}
{{#dtdd "mousedown, mouseup
"}}
The mouse button is newly down or up.
{{/dtdd}}
{{#dtdd "keydown, keypress, keyup
"}}
The user presses a keyboard key. `keypress` is most useful for
catching typing in text fields, while `keydown` and `keyup` can be
used for arrow keys or modifier keys.
{{/dtdd}}