valuechange event

by mark69_fnd

HTML

<input type='text' value='abc'/>

JavaScript

YUI().use('node', 'event-valuechange', 'yui-later', function(Y) {
    var body, node, i = 0, countEvents = 0;
    (body = Y.one('body')).addClass('yui3-skin-sam');
    (node = Y.one('input')).on('valuechange', function(){
        countEvents += 1;
    });
    
    function run(){
        node.set('value', i);
        if (i < 20){
            i += 1;
            Y.later(Math.floor(Math.random()*1001) + 1000, null, run);
        } else {
            body.append('<br/> update count = ' + i + ', event count (should be 0) = ' + countEvents);
        }
    }
    
    run();
});