Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added some docs in README

  • Loading branch information...
commit dea975e36ff59ddb98d3e9b300262dae66a1959e 1 parent 2f94bbc
@trevnorris authored
Showing with 44 additions and 0 deletions.
  1. 0  README
  2. +44 −0 README.md
View
0  README
No changes.
View
44 README.md
@@ -0,0 +1,44 @@
+jqml - jQuery JsonML Translator
+
+The library is included in the `src/` directory in full and minified forms.
+Figured I should include some code examples, so here it goes:
+
+To create a new element as a jQuery object just pass in the JsonML.
+
+```javascript
+$.jqml([ 'div', {
+ 'id' : 'mydiv',
+ 'class' : 'colors borders'
+}, [ 'p' ]]);
+```
+
+One thing I like about my little plugin is that it ties into the jQuery event model.
+So you can attach events to the elements you're creating as they're being created.
+Then easily attach the element to something else.
+
+```javascript
+$.jqml([ 'nav', [ 'a', {
+ 'href' : '#link',
+ 'click' : function( e ) {
+ e.preventDefault();
+ // do more stuff
+ }
+}]]).prependTo( 'body' );
+```
+
+Also say you need to create a template that prints table rows based on data received from the server.
+Well, just create an immediately executing anonymous function in the JsonML for a quick little template.
+
+```javascript
+$.jqml([ 'table', (function( data ) {
+ var dataRows = [ 'tbody' ];
+ for ( var i = 0; i < data.length; i++ ) {
+ dataRows.push([ 'tr', [ 'td', data[ i ]]]);
+ }
+ return dataRows;
+}( data ))]);
+```
+
+If you have a problem, post an issue.
+The plugin is super light weight, under 1K minified, so troubleshooting shouldn't be too hard.
+And let me know if you have any features/improvements you'd like to see.
Please sign in to comment.
Something went wrong with that request. Please try again.