Created
August 8, 2012 15:55
-
-
Save hciudad/3296174 to your computer and use it in GitHub Desktop.
Log object attributes using the .watch() method. This is only supported by Firefox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To log individual attributes | |
myWidget.options.watch('displayHeight', function(id, oldval, newval) { | |
console.log('id = %s, oldval = %s, newval = %s', id, oldval, newval); | |
return newval; | |
}); | |
myWidget.options.watch('displayWidth', function(id, oldval, newval) { | |
console.log('id = %s, oldval = %s, newval = %s', id, oldval, newval); | |
return newval; | |
}); | |
// To log all attributes in an object | |
for (i in myWidget.options) { | |
myWidget.options.watch(i, function(id, oldval, newval) { | |
console.log('id = %s, oldval = %s, newval = %s', id, oldval, newval); | |
return newval; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment