- Requires jQuery v1.3
- Requires a selector engine (provided by you).
- Have a look at the file jsonq.engine.js to see an example selector engine.
Let's assume that your selector engine (more about that later) is defined
in a file called engine.js and the engine object it defines is Engine
.
Load the scripts in your document head as follows:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="selectomatic.js"></script>
<script type="text/javascript" src="your.selector.engine.js"></script>
Then you can instntiate your Selectomatic
like this:
Q = Selectomatic(new Engine());
Now the Q
object is a jQuery-like object, with all the awesome collections
managment and chaining patterns. You can then do something like this with it:
Q("[?price<12.50]")
.filter("[?name^='super']")
.each(function(elem, index) {
this.price++;
})
.json();
This is the framework for creating queryable collections objects. All the methods are similar to what you would find in jQuery, but with the CSS selector engine and DOM specificity removed and abstracted out.
- each():
- extend():
- grep():
- makeArray():
- map():
- inArray():
- merge():
- unique():
- isArray():
- isFunction():
- trim():
- param():
- find():
- each():
- size():
- eq():
- get():
- index():
- filter():
- is():
- map():
- not():
- slice():
- add():
- andSelf():
- end():
- pushStack():
- setArray():
If someone is interested hit me up and I'll put more docs here.
This is a query engine for selectomatic.js.
-
(object): Constructs a new instance and sets its collection to object. This "wraps" object in a selectomatic object, you could say.
-
json(object): Returns a JSON string representation of the object.
-
find(query): Selects from the current collection objects satisfying the query.
-
pick(array, invert): Picks the properties specified in array from each element in the selection, deleting all other properties. Basically, if you think of the JSON data as a table, this selects the columns. If the invert argument is true then the selection is inverted.
-
json(): Returns a JSON representation of the selection array.