document.observe('dom:loaded', function() {
Solution 1
you can observe elements changing like this
$('element').observe('change',function(e){ } );
This is reserved for form elements though - textarea, select and input.
The final code would look something like:
document.observe('dom:loaded', function() {
$('element').observe('change',function(e){
// do something here
});
});
Solution 2
The 'change' method is defined only for 'input', 'textarea' and select elements, not for general elements.
The "dom:loaded" event is a user-defined event (as far as the browser is concerned) defined by the Prototype library. I don't believe that it is usable as any kind of template for a dom:changed event.
What you are looking for are DOM mutation events, such as DomSubtreeModified (see 1). But I don't believe these are widely supported in browsers yet.
![thenengah](https://lh6.googleusercontent.com/-ClhTuVExL4w/AAAAAAAAAAI/AAAAAAAAAAc/C6ZXYYMKPKs/photo.jpg?sz=256)
thenengah
I taught ESL after university, then I started making things for the internet. My favorite tools are mac, ubuntu, vim, tmux, bash, git, javascript/node/express, ruby/rails, react, redux, bootstrap, sass, webpack, gulp, babel, jest, mysql, mongodb, redis, neo4j, rabbitMQ, ELK, nginx, jenkins, AWS.
Updated on December 29, 2020Comments
-
thenengah over 3 years
Is there a way to have this prototype js trigger only when dom is changed and not loaded?