This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"glossary": { | |
"title": "example glossary ABC", | |
"GlossDiv": { | |
"title": "S", | |
"GlossList": { | |
"GlossEntry": { | |
"ID": "SGML", | |
"SortAs": "SGML", | |
"GlossTerm": "Standard Generalized Markup Language", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/12042260/how-to-use-the-javascript-module-pattern-in-a-real-example | |
var myApp = (function() { | |
var someElement = $("#foo"); //some element I know I'll use lots | |
var addMessage = function(message) { | |
$.ajax({ | |
url: '/test', | |
type: 'POST', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#test_form").delegate("input:not([id*='_submit']), select", "blur", function(e) { | |
// Does something | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
TABLE.repeatHeader('#celebs', 10) | |
}); | |
var TABLE = {}; | |
TABLE.repeatHeader = function(table, every){ | |
$(table).each(function() { | |
var $this = $(this); | |
var rowsLen = $this.find('tr:not(:first)').length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
TABLE.fixHeader('table') | |
}); | |
var TABLE = {}; | |
TABLE.fixHeader = function(table) { | |
$(table).each(function() { | |
var $table = $(this); | |
var $thead = $table.find('thead'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ir { | |
border: 0; | |
font: 0/0 a; | |
text-shadow: none; | |
color: transparent; | |
background-color: transparent; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.shuffleChildren = (function(){ | |
function fisherYatesShuffle(arr) { | |
// Fisher-Yates shuffle has been proven | |
// to be more random than the conventional | |
// arr.sort(function(){return Math.random()-.5}) | |
// http://www.robweir.com/blog/2010/02/microsoft-random-browser-ballot.html | |
var i = arr.length, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family: Helvetica, Verdana | |
} | |
p { | |
padding: 7px 10px; | |
} | |
#demo { | |
border: 1px solid #999; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
_.bindAll() ensures that all the functions you indicate are always invoked in the specified context. This is especially useful for event callbacks, as their context is always changing. | |
*/ | |
Account = Backbone.Model.extend({ | |
initialize: function() { | |
_.bindAll(this, 'removeElement'); | |
}, | |
removeElement: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*el is created using the attributes from the view’s tagName, className, or id properties. If none of these is specified, el is an empty div: | |
*/ | |
var UserView = Backbone.View.extend({ | |
tagName: "span", | |
className: "users" | |
}); | |
// Binding a view onto an existing element in the page. | |
// Make sure the view is set up after the page has loaded. |
NewerOlder