2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('node-load', function (Y, NAME) {
11 * Extended Node interface with a 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 the remote content.
49 * @param {String} url The URL to load via XMLHttpRequest.
50 * @param {String} selector An optional selector representing a subset of an HTML document to load.
51 * @param {Function} callback An optional function to run after the content has been loaded.
54 Y.Node.prototype.load = function(url, selector, callback) {
55 if (typeof selector == 'function') {
62 complete: this._ioComplete
64 arguments: [selector, callback]
72 }, '3.13.0', {"requires": ["node-base", "io-base"]});