jCreate

jCreate is a new special event for jQuery. Just use .on('create', ..); the callback will be triggered when elements are created on the page.

View project on GitHub

Build Status Bower Version

jCreate

jCreate is a plugin for jQuery that adds a new bindable event.

Now you can do something cool when one or more elements are created and are available on the page.

See it in action with CodePen.

Install with Bower

You can install jCreate using Bower:

bower install --save jquery-jcreate

And now you can include it in you project with a <script> tag.

<script type="text/javascript" src="jquery.jcreate.min.js"></script>

How to use

jCreate works with the jQuery Event Delegation.

// bind 'create' event.
$( '#dataTable tbody' ).on( 'create', 'tr', function() {
    console.log( $( this ).text() );
});

// add a new 'row'.
$( '#dataTable tbody' ).append('<tr><td>this is a new row!</td></tr>');

jQuery Support

Since I use the last version of jasmine-jquery library in order to test my own plugin, I cannot ensure that the plugin works with jQuery 1.7 and below, due to the fact that jasmine-jquery uses methods that were introduced in jQuery 1.8.

Jcreate in action

Development

 Install Grunt and Bower

To install Grunt and Bower, you must first download and install node.js.

Then, using the command line:

# install `grunt-cli` globally
npm install -g grunt-cli

# install `bower` globally
npm install -g bower

# navigate to the root of your project, then run
npm install
bower install

Available Grunt tasks

  • jshint Validate files with JSHint.
  • jasmine Run jasmine specs headlessly through PhantomJS.
  • uglify Minify files with UglifyJS.
  • watch Run predefined tasks whenever watched files change.
  • test Alias for "jshint", "jasmine" tasks.
  • build Alias for "test", "uglify", "sync" tasks.