Skip to content

Instantly share code, notes, and snippets.

Y.mix(Y.NodeList.prototype, {
slice : function (start, end) {
return Y.all(this._nodes.slice(start, end));
}
});
YUI().use('widget-base', 'widget-stdmod', 'base-build', function (Y) {
var headerContent = '<a href="#" id="someButton">Click me</a>';
var myWidget = Y.Base.create('my-widget', Y.Widget, [Y.WidgetStdMod], {
_headerButton : null, // ref to btn
renderUI : function () {
this.setStdModContent(Y.WidgetStdMod.HEADER, headerContent, Y.WidgetStdMod.REPLACE);
var header = this.getStdModNode(Y.WidgetStdMod.HEADER);
this._headerButton = header.one('#someButton'); // Returns null
"""
Copyright (c) 2010, Greg Hinch
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFIT
var Book = Y.Base.create('book', Y.Model, [], {}, {
ATTRS : { // use the normal attribute config here, including the validation & parsing (setter)
author : {},
title : {},
publisher : {}
},
EDITORS : { // define editors for each key here
author : {fn : Y.Model.EDIT.Choice, cfg : {choices : [...]},
title : Y.Model.EDIT.Text
}
var data = [
{author : {surname : 'Roberts', firstname : 'Gregory David'}, title : 'Shantaram', published : (new Date('09/25/2005'))},
{author : {surname : 'Gibson', firstname : 'William'}, title : 'Neuromancer', published : (new Date('07/01/1984'))},
{author : {surname : 'Rowling', firstname : 'J.K.'}, title : 'Harry Potter', published : (new Date('06/30/1997'))},
{author : {surname : 'Simon', firstname : 'Ted'}, title : 'Jupiter\'s Travels', published : (new Date('01/01/1979'))},
{author : {surname : 'Tolkien', firstname : 'J.R.R.'}, title : 'The Hobbit', published : (new Date('09/21/1937'))}
];
var ds = new Y.DataSource.Local({
source : data,
var Book = Y.Base.create('book', Y.Model, [], {}, {
PRIMARY_KEY : 'id',
ATTRS : {
author : {},
id : {},
title : {},
published : {},
format : {}
}
});
function WidgetParentStdMod () {
Y.before(this._initParentStdMod, this, 'renderUI');
Y.before(function () {
console.log('halt?');
return new Y.Do.Halt('ParentStdMod halted this');
}, this, '_renderChildren');
Y.after(this._renderChildrenAfterSync, this, 'syncUI');
}
<!doctype html>
<html>
<head>
<title>test</title>
<script type="text/javascript" src="js/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<select id="typeChoice">
<option>Select one</option>
<option value="fruits">Fruits</option>
<!DOCTYPE html>
<html>
<head>
<title>AC Test</title>
<script src="http://yui.yahooapis.com/3.3.0pr3/build/yui/yui-min.js"></script>
</head>
<body>
<input type="text" id="n" value="foo">
<script type="text/javascript">
var AutoCompleteMultiQueryDelim = Y.Base.create('ac-multi-query-delim', Y.Plugin.Base, [], {
_beforeParseValue : function (value) {
return new Y.Do.Prevent();
},
_newParseValue : function (value) {
var delim = this.get(HOST).get(QUERY_DELIMITER),
delimIndex = 0,
useDelim;
value = value || '';