Skip to content

Instantly share code, notes, and snippets.

<ul id="thinger">
<li>
<input type="button" id="button_1" value="button 1" />
<div id="panel_1" class="panel">Panel 1</div>
</li>
<li>
<input type="button" id="button_2" value="button 2" />
<div id="panel_2" class="panel">Panel 2</div>
</li>
<li>
dojo.addOnLoad(function() {
dojo.declare('Thinger', null, {
names : [ 'Pete', 'Nikolai', 'Dylan', 'Jared', 'Bill' ],
greetings : [ 'Ohai', 'Hello', 'Guten tag', 'Hola' ],
constructor : function(node, name) {
this.node = node;
name && this.forceName(name);
window.xxx = 123;
(function() { var y = xxx; var xxx = 456; alert(y); })();
diff --git a/src/core.js b/src/core.js
index e1a3a6d..e4b74d9 100644
--- a/src/core.js
+++ b/src/core.js
@@ -535,6 +535,8 @@ jQuery.extend({
// args is for internal usage only
each: function( object, callback, args ) {
+ if (object === undefined) { return; }
+
// instead of this
$('#myList li').each(function() {
var $li = $(this), $div = $li.find('div.content');
$li.data('contentDiv', $div);
});
// i want to do this
$('#myList li').data('contentDiv', function() { return $(this).find('div.content'); });
console.log(context.cache());
if(context.cache().recentOrders){
context.partial('templates/previous_orders/recent.mustache', PreviousOrdersView(context.cache().recentOrders), function(html) {
$('.recent_orders').html(html);
});
console.log('from cache');
}else{
var url = context.recent_orders_url(email, 5);
$.ajax({
url: url,
var foo = 'hello';
(function() {
// even tho foo is defined outside of this closure,
// the var foo declaration below initializes the variable
// inside the closure immediately -- any attempt to access
// foo inside the closure will use the local version, even
// an attempt before the var statement.
alert(foo || 'foo is not defined yet!'); // 'foo is not defined yet'
(function(d, $) {
d.ready(function() {
d.connect('searchForm', 'submit', function(e) {
e.preventDefault();
var myVal = $('input', this)[0].value;
d.xhrGet({
url : 'search.php',
content : { term : myVal },
handleAs : 'json',
load : function(resp) {
dojo.provide('my.app.Strings');
(function(d) {
var baseDir = '/str/',
chain = [ baseDir + 'base.json' ];
my.app.str = {};
if (window.APP_INSTANCE) {
function isAlphanumeric(c) {
if (((c < '0') || (c > '9')) && ((c < 'A') || (c > 'Z'))) {
if (c >= 'a') {
return (c <= 'z');
}
return false;
}
return true;
}