2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 YUI.add('node-load', function(Y) {
11 * Extended Node interface with an basic IO api.
13 * @submodule node-load
17 * The default IO complete handler.
21 * @param {String} code The response code.
22 * @param {Object} response The response object.
23 * @param {Array} args An array containing the callback and selector
26 Y.Node.prototype._ioComplete = function(code, response, args) {
27 var selector = args[0],
32 if (response && response.responseText) {
33 content = response.responseText;
35 tmp = Y.DOM.create(content);
36 content = Y.Selector.query(selector, tmp);
38 this.setContent(content);
41 callback.call(this, code, response);
46 * Loads content from the given url and replaces the Node's
47 * existing content with it.
49 * @param {String} html The markup to wrap around the node.
50 * @param {String} selector An optional selector representing subset
51 * @param {Function} callback An optional function to run after the content has been loaded.
55 Y.Node.prototype.load = function(url, selector, callback) {
56 if (typeof selector == 'function') {
63 complete: this._ioComplete
65 arguments: [selector, callback]
73 }, '3.3.0' ,{requires:['node-base', 'io-base']});