3
Copyright 2012 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
7
YUI.add('node-load', function(Y) {
10
* Extended Node interface with a basic IO API.
12
* @submodule node-load
16
* The default IO complete handler.
20
* @param {String} code The response code.
21
* @param {Object} response The response object.
22
* @param {Array} args An array containing the callback and selector
25
Y.Node.prototype._ioComplete = function(code, response, args) {
26
var selector = args[0],
31
if (response && response.responseText) {
32
content = response.responseText;
34
tmp = Y.DOM.create(content);
35
content = Y.Selector.query(selector, tmp);
37
this.setContent(content);
40
callback.call(this, code, response);
45
* Loads content from the given url and replaces the Node's
46
* existing content with the remote content.
48
* @param {String} url The URL to load via XMLHttpRequest.
49
* @param {String} selector An optional selector representing a subset of an HTML document to load.
50
* @param {Function} callback An optional function to run after the content has been loaded.
53
Y.Node.prototype.load = function(url, selector, callback) {
54
if (typeof selector == 'function') {
61
complete: this._ioComplete
63
arguments: [selector, callback]
71
}, '3.5.0' ,{requires:['node-base', 'io-base']});