Skip to content

Commit

Permalink
Update documentation. Fix version in configuration files and source f…
Browse files Browse the repository at this point in the history
…iles.
  • Loading branch information
RickStrahl committed Jan 19, 2016
1 parent 31acea8 commit aaaf64b
Show file tree
Hide file tree
Showing 6 changed files with 694 additions and 436 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-watch-dom",
"version": "1.16.0",
"version": "1.21.0",
"main": "jquery-watch.js",
"license": "MIT",
"ignore": [
Expand Down
5 changes: 2 additions & 3 deletions jquery-watch.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// <reference path="jquery.js" />
/*
jquery-watcher
Version 1.20 - 12/21/2015
© 2014-2015 Rick Strahl, West Wind Technologies
Version 1.21 - 1/19/2016
© 2014-2016 Rick Strahl, West Wind Technologies
www.west-wind.com
Licensed under MIT License
http://en.wikipedia.org/wiki/MIT_License
Expand All @@ -26,7 +26,6 @@ http://en.wikipedia.org/wiki/MIT_License
/// Option to set - see comments in code below.
/// </param>
/// <returns type="jQuery" />

var opt = $.extend({
// CSS styles or Attributes to monitor as comma delimited list
// For attributes use a attr_ prefix
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-watch",
"version": "1.20.0",
"version": "1.21.0",
"description": "This small jQuery plug-in allows you to monitor changes to any DOM element's CSS styles, attributes or properties and fires a callback in response to any change in the monitored styles or attributes.",
"main": "jquery-watch.js",
"scripts": {
Expand All @@ -11,10 +11,13 @@
"url": "https://github.com/RickStrahl/jquery-watch"
},
"keywords": [
"jquery-watch",
"monitor",
"DOM-events",
"change-events",
"jquery"
"jquery",
"jquery-plugin",
"ecosystem:jquery"
],
"author": "Rick Strahl, West Wind Technologies",
"license": "MIT",
Expand Down
21 changes: 20 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ There are two boxes #notebox and #shadow and what we want to do is monitor chang
The following code monitors #notebox so we can tell when a monitored value is changed:

```javascript
<script>
var el = $("#notebox");
el.draggable();

Expand Down Expand Up @@ -234,6 +233,26 @@ When you run this code you'll essentially see #shadow follow around the #notebox

Note that the code above doesn't actually rely on the parameters passed into the `watchShadow` function, but instead does its own checks to see what needs updating. In fact this code simply updates all relevant properties whether they have changed or not. While less efficient it allows for simpler code and depending on how much change you need to do on the DOM, this can be very fast regardless. Your mileage may vary. If you have larger changes you need to affect, using the specific property to update the UI might be more appropriate.

### Watching Child Elements
You can also monitor changes to child nodes by setting `.watchChildren` to `true` and then looking at the mutation record to figure out if nodes have been removed or added:

```javascript
$list.watch({
properties: 'prop_innerHTML',
watchChildren: true,
callback: function (data, i, mutations) {

mutations.forEach(function(record) {
if (record.type === 'childList' && record.removedNodes.length > 0) {
console.info('removed item');
} else if (record.addedNodes.length > 0) {
console.info('added item');
}
});
}
});
```

## Browser Support
This plug-in will work with just about any browser, as it has a fallback for legacy browsers using interval polling. Modern browsers use an efficient API to get notified of changes by the browser.

Expand Down
Loading

0 comments on commit aaaf64b

Please sign in to comment.