nodelist.html revision e56c4e11f404542db23efd22779d04fd7e8ff5ea
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>FIXME</title>
<script type="text/javascript" src="/build/yui/yui.js"></script>
<script type="text/javascript" src="/build/event-custom/event-custom.js"></script>
<script type="text/javascript" src="/build/event-simulate/event-simulate.js"></script>
<script type="text/javascript" src="/build/event/event.js"></script>
<script type="text/javascript" src="/build/oop/oop.js"></script>
<script type="text/javascript" src="/build/base/base.js"></script>
<script type="text/javascript" src="/build/attribute/attribute.js"></script>
<script type="text/javascript" src="/build/dom/dom-debug.js"></script>
<script type="text/javascript" src="/build/node/node-debug.js"></script>
<style type="text/css">
</style>
</head>
<body>
<div id="demo" class="foo">
<p id="lorem">lorem</p>
<p title="ipsum">ipsum</p>
<p>dolor</p>
<p>sit</p>
</div>
<script type="text/javascript">
YUI().use('*', function(Y) {
var a = ['foo', 'bar', 'baz:', 'fool'],
b = ['foo', 'baz', 'boo', 'bool'];
nodelist = Y.all('p');
//nodelist.set('style.color', 'red');
node = Y.get('p[title]');
/*
1. set title on all nodes
store initial value === prevVal
2. provide prevVal array in handler
3. fire node titleChange
4. fire nodelist titleChange
*/
node.on('innerHTMLChange', function(e) {
e.preventDefault();
e.newVal = 'hijacked val';
this._defAttrChangeFn(e);
console.log('Node: ' + e.type + ': ' + e.target._yuid);
});
//node.set('innerHTML', 'new content from Node');
//node.setStyle('color', 'red');
nodelist.setStyle('color', 'red');
console.log(Y.all('body').get('nodeName'));
/*
console.log(Y.get('body').get('firstChild.nodeName'));
Y.get('body').on('firstChildChange', function(e) {
console.log(e);
e.preventDefault();
});
console.log(Y.get('body').set('firstChild.nextSibling.innerHTML', 'foo'));
node.after('innerHTMLChange', function(e) {
console.log('Node: afterInnerHTMLChange');
});
nodelist.on('innerHTMLChange', function(e) {
//console.log('NodeList: ' + e.type + ': ' + e.target);
});
var onClick = function(e) {
//e.preventDefault();
console.log('node click');
};
nodelist.on('click', onClick);
Y.get('#demo').addNode('<p>injected content</p>');
nodelist.on('refresh', function(e) {
e.added.on('click', onClick);
});
nodelist.refresh();
nodelist.set('innerHTML', 'new content from NodeList');
console.log(Y.get('#demo').get('children').set('innerHTML', 'foo'));
console.log(Y.get('#demo').hasClass('foo'));
console.log(Y.get('#demo').addClass('bar'));
console.log(Y.get('#demo').hasClass('bar'));
console.log(nodelist.item(0).get('id'));
nodelist.each(function(n) {
n.set('innerHTML', 'set by nodelist.each()');
});
*/
});
</script>
</body>
</html>