Skip to content

Instantly share code, notes, and snippets.

John Urberg jurberg

Block or report user

Report or block jurberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jurberg / advice.js
Last active Dec 27, 2015
sample advice extension. forgot the origins of this...
View advice.js
(function (exports) {
//mixin augments target object with around, before and after methods
//method is the base method, advice is the augmenting function
exports.withAdvice = function() {
['before', 'after', 'around'].forEach(function(m) {
this[m] = function(method, advice) {
if (typeof this[method] == 'function') {
View testDialog.css
.test-dialog-content {
font-weight: normal;
color: red;
View testDialog.js
var TestDialog = (function($) {
var $dialog;
$(function() {
$dialog = $('#test-dialog');
autoOpen: false,
width: 300,
height: 200
View index.gsp
<!DOCTYPE html>
<meta name="layout" content="main"/>
<title>Javascript Components</title>
<button onclick="TestDialog.openDialog();">OpenDialog</button>
<g:render template="/layouts/test-dialog"/>
View ApplicationResources.groovy
modules = {
application {
resource url:'js/application.js'
test_dialog {
dependsOn 'jquery, jquery-ui'
resource url:'css/testDialog.css'
resource url:'js/testDialog.js'
View _test-dialog.gsp
<r:require module="test_dialog"/>
<div id="test-dialog" title="Test Dialog">
<div class="test-dialog-content">
This is a test.
View requirejs-url-setup.js
UrlMappings.config.forEach(function(mapping) {
app[mapping.verb](mapping.route, function(req, res) {
require(['app/controller/' + mapping.controller], function(Controller) {
Controller[mapping.action](req, res);
View require-express-setup.js
app.all('/:controller/:action/:id?', function(req, res) {
require(['app/controller/' + req.params.controller], function(Controller) {
Controller[req.params.action](req, res);
app.all('/:controller', function(req, res) {
require(['app/controller/' + req.params.controller], function(Controller) {
Controller.index(req, res);
View define-example.html
<a onclick="view.person.showPerson(); return false;">Show person</a>
<div id="person-div"></div>
View define-example.js
define('view/person', ['domain/person', 'jQuery', 'window'], function(Person, $, Win) {
var person = Person.createPerson();
return {
showPerson: function() {
Win.alert('Person updated!');
You can’t perform that action at this time.