Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="jquery.js" type="text/javascript"></script>
<script src="cufon-yui.js" type="text/javascript"></script>
<script src="archer-medium.font.js" type="text/javascript"></script>
<script src="archer-semibold.font.js" type="text/javascript"></script>
<script src="archer-bold.font.js" type="text/javascript"></script>
$(function() {
$('.checkbox input:checkbox').change(function(){
var service = $(this).parent().next().find('label:first');
if($(this).is(':checked')) {
service.addClass('active');
} else {
service.removeClass('active');
}
}).triggerHandler('change');
.header_wrapper
.header.clearfix
%h1= link_to "Kashless", "/"
%ul.menu
%li= link_to "Find a free item", listings_path
%li= link_to "Give Away", new_listing_path
- if logged_in? && current_user.has_role?(:admin)
%li= link_to "Users Admin", admin_users_path
<div class="header_wrapper">
<div class="header clearfix">
<h1><a href="/">Kashless</a></h1>
<ul class="menu">
<li>
<%= link_to "Find a free item", listings_path %>
</li>
<li>
<%= link_to "Give Away", new_listing_path %>
// Outer function just allows use of $ or jQuery (for jQuery Plugins)
(function($){
// Creates a jQuery wrapper method so methods can be attached to jQuery wrapped sets eg:
// $('form').fixieAjaxForm()
$.fixieAjaxForm = function(successCallback) {
// $(this) == $('form') inside this function
$(this).ajaxForm(function(str) {
var data = $.parseJSON(str);
$(this).find('label.error').removeClass('error');
if (data.errors.length === 0) {
(function($){
$.fixieAjaxForm = function(onSuccess) {
// $('form').fixieAjaxForm()
// $(this) == $('form') inside this function
$(this).ajaxForm(function(str) {
var data = $.parseJSON(str);
$(this).find('label.error').removeClass('error');
if (data.errors.length === 0) {
$(this).resetForm();
onSuccess(data);
Playing with gist
Cool?