Max SchmittMS
27th August 2013

jQuery Component for Crafty

I'm currently working on a little puzzle-game called pozzle, which uses the Crafty engine. Today I'm working on cleaning up my UI-code.

Here is a little jQuery component, that makes a jQuery-wrapper of the entity's DOM-element available. You call it by using this.$element, where this refers to your entity with the JQuery component attached.

Crafty.c('JQuery', {
init: function() {
this.bind('Change', this._rebindJQuerySelector)
remove: function() {
this.unbind('Change', this._rebindJQuerySelector)
_rebindJQuerySelector: function() {
this.$element = $(this._element)

Need help on a project?

I'm available for freelance work.
Send me an email! Or find out more about my services.