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
class LazyCollection extends Backbone.Collection | |
indexQuerystring: 'index' | |
index: 1 | |
lastLength: 0 | |
fetch: (options) -> | |
options or= {} | |
if options.reset | |
@index = 1 | |
@lastLength = 0 | |
else |
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
public class ExceptionHandlerFilter : IExceptionFilter | |
{ | |
... | |
public void OnException(ExceptionContext context) | |
{ | |
// Are you kidding me??? | |
var controllerDescriptor = (ControllerDescriptor)new ReflectedControllerDescriptor(context.Controller.GetType()); | |
var actionDescriptor = (ReflectedActionDescriptor)controllerDescriptor.FindAction(context, context.RouteData.Values["action"].ToString()); | |
if (actionDescriptor.MethodInfo.ReturnType == typeof(JsonResult)) |
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
# Proxies ajax errors to the event aggregator | |
define 'ajaxerrorproxy', ['jquery', 'postal'], ($, postal) -> | |
options = {} | |
$(document).ajaxError (error, xhr, settings, thrownError) -> | |
json = !xhr.getResponseHeader('content-type').indexOf('application/json') | |
status = options[xhr.status] ? {} | |
channel = postal.channel "error.ajax.#{status.alias ? xhr.status}" | |
channel.publish | |
status: status.alias ? xhr.status | |
message: status.message ? thrownError |
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
public class PostHandler | |
{ | |
... | |
public AjaxContinuation Execute(Model request) | |
{ | |
var updatedModel = Map(_addWidgetService.Add(Map(request))); | |
// How do I get my updatedModel back to the client? | |
return AjaxContinuation.Successful(); | |
} | |
} |
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
require.config | |
paths: | |
order: '/content/scripts/require/order' | |
jquery: '/content/scripts/jquery' | |
define 'underscore', ['order!/content/scripts/underscore.js'], -> _ | |
define 'backbone', ['order!/content/scripts/backbone.js'], -> Backbone | |
require [ | |
'order!jquery', |
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
window.error = (message) -> | |
console.log message | |
phantom.exit 1 | |
#window.onerror = (message) -> | |
# console.log message | |
# phantom.exit 1 | |
Date.prototype.elapsed = -> (new Date() - @) / 1000; |
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
<html> | |
<title><use content="title" /></title> | |
<head> | |
<!-- | |
These url's are all relative to the master layout but will | |
not be valid for views that exist in different folders. | |
I'm hoping to keep the url's relative but I'm not sure if | |
there is a way to accomplish that in a master layout. |
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
(function() { | |
var plugin = function($) { | |
$.dialog = function (option) { | |
var content = '<div class="modal hide ' + option.css + '">'; | |
content += '<div class="modal-header">'; | |
content += '<a class="close" data-dismiss="modal">×</a><h3>' + option.title + '</h3>'; | |
content += '</div>'; | |
content += '<div class="modal-body">' + option.body + '</div>'; | |
content += '<div class="modal-footer">'; | |
content += '<a class="btn btn-primary ok">' + option.button + '</a>'; |
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
(function() { | |
var plugin = function(Backbone) { | |
LazyCollection = Backbone.Collection.extend(); | |
LazyCollection.prototype.indexQuerystring = 'index'; | |
LazyCollection.prototype.index = 0; | |
LazyCollection.prototype.lastLength = -1; | |
LazyCollection.prototype.fetch = function(options) { |
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
(function() { | |
var plugin = function($) { | |
$.fn.validate = function (selectors, predicate, message) { | |
if (!$.isArray(selectors)) selectors = [selectors]; | |
var controlGroups = []; | |
var values = []; | |
for (index in selectors) { | |
var input = this.find(selectors[index]); | |
if (input.length == 0) throw 'Selector invalid: ' + selectors[index]; | |
input = $(input[0]); |