Plugins

The plugins site is currently in development.

We've been looking to provide a higher-quality, spam-free experience at the plugins site for some time, and a major error on our part forced us to shut down the current site before we could put the new one in place. We are developing a new site, and you can follow along with its development on GitHub. For more information about this transition, including steps you can take as a plugin author to prepare, please read our post about what's going on.

jQuery Watch


This extension method to jQuery adds a timer driven check in order to implement a watch/unwatch methods similar to SpiderMonkey's Object.prototype.watch/unwatch.

function watchCallbackExample(propertyName, oldValue, newValue) {
    alert("o." + propertyName + " changed from " + oldValue + " to " + newValue);
}

//bind a watch event to a callback
jQuery(o).watch("someProperty", watchCallbackExample)

//unbind a watch event from a callback
jQuery(o).unwatch("someProperty", watchCallbackExample);

//unbind all callbacks from a watched property
jQuery(o).unwatch("someProperty");

//unbind all callbacks for all watched properties
jQuery(o).unwatch();

//unbind a given callback from all watched properties
jQuery(o).unwatch(null, watchCallbackExample);

There are a few open bugs in this code, I will try to get it updated this coming weekend. The plugin itself I wound up not using, and think it's not a great fit upon reflection, but it is what it is at this point. I would suggest anyone considering this plugin to reconsider their problem domain and think about using Reactive Extensions for JavaScript which has some jQuery integration points.

Downloads



5
Your rating: None Average: 5 (1 vote)