Skip to content

Instantly share code, notes, and snippets.

function Foo() {
/* constructor stuff */
}
// apply a class prototype that includes private and public methods
(function () {
function private(x) {
return x + 1;
}
// This assumes the file names are directly mappable to the module names declared
// in the YUI.add() calls inside those files.
YUI({
modules: {
'myapp.tests.core': { fullpath: '/path/to/core.js' }
}
}).use('myapp.tests.core', function (Y) {
var tests = [ '0001','0002', ... ],
i, len;
document.getElementById('x').innerHTML =
'<input type="checkbox" name="foo" value="1">' +
'<input type="checkbox" name="foo" value="2">' +
'<input type="checkbox" name="foo" value="3">' +
'<input type="checkbox" name="foo" value="4">' +
'<input type="checkbox" name="foo" value="5">';
alert(document.getElementsByName('foo').length);
(function () {
YAHOO.namespace('KVC');
// YAHOO.util.Event.throwErrors = true; // for debugging.
var xdrConfig = {
id : 'flash',
yid : Y.id,
src : '/assets/scripts/kvc/io.swf?t=' + new Date().valueOf().toString()
<form>
<fieldset id="fields"></fieldset>
</form>
<script>
onload = function () {
var fields = document.getElementById('fields'),
frm = fields.parentNode;
(function() {
var YCM = YAHOO.util.Connect,
pending = [];
function _handleStart(e, a) {
console.log("Transaction " + a[0].tId + " is starting.", "info", "example");
}
function _handleSuccess(o) {
var area = YAHOO.util.Dom.get('output');
/**
* The History Lite utility is similar in purpose to the YUI Browser History
* utility, but with a more flexible API, no initialization or markup
* requirements, limited IE6/7 support, and a much smaller footprint.
*
* @module history-lite
*/
/**
* @class HistoryLite
// How to snoop on log statements from another YUI instance
YUI().use('event', function (Y) {
Y.Global.on('yui:log', function (msg, cat, src) {
// You'll need to escape msg if you want to display it
});
});
<!doctype html>
<html>
<head>
<title>YUI3 Sandbox</title>
</head>
<body>
<script src="http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js"></script>
<script>
delete Object.prototype.toJSON;
delete Array.prototype.toJSON;
delete Hash.prototype.toJSON;
delete Number.prototype.toJSON;
delete Boolean.prototype.toJSON;
delete String.prototype.toJSON;
Object.toJSON = YAHOO.lang.JSON.stringify;