nQuery (beta)
nQuery lets you use $() on the server to manipulate the browser side in realtime. It accomplishes this using Socket.io, Dnode, Browserify, and either jquery or Zepto.
nQuery is a minimalist DOM manipulation framework, it's fast, and its bringing all of the jquery methods to the server so you dont have to write (or serve!) any client side javascript in order to make a realtime browser application.
The current API matches both jquery and zepto counterparts, so you can include either one on the client side.
The goal is to have a full DOM manipulation framework that works in realtime from the server side. This means you are mostly just setting attributes, html, values and binding events in jquery just like you would normally, but these methods work seamlessly with the server side of your code.
Install
$ npm install nodeQuery
Usage
Create a file to serve up jquery and nquery and put it in /public
Create an app.js file
var Express = dnode = nQuery = express = Express; var { $;}; nQuery ; express ; dnode ;
Visit the html file you created to see "Hello World"
Notes
Remember that just because you can write jquery on the serer doesnt mean you will always want to. A click event being bound to the server for a form is amazingly powerful, but if your mouseover or swipe event only changes the display features of your app (i.e. color, size) then it most likely still belongs on the client to reduce the server load. There is a method in nQuery.js similar to $(document).ready() for the client as well as the server. On the client it is nQuery.ready()
Methods
So far only a limited number of jquery/zepto methods are available, but these include some of the most powerful functionality in jquery. You may create live bindings to events and you can use all of the event types that are available with jquery or zepto to do this, including:
swipe swipeLeft swipeRight swipeUp swipeDown doubleTap tap longTap focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout change select keydown keypress keyup error
Sample usage of methods on the server:
nQuery;
More Examples:
Check out the todos app written with tubes and nquery
Check out the examples folder for a few very simple demos. There are two different clocks that run based on the server time, a twitter search app that implements backbone conventions and a simple hello world app.
MIT License