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
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
# 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 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
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
define 'underscore', ['path/to/underscore.js'], -> _ | |
define 'backbone', ['underscore', 'jquery', 'order!path/to/backbone.js'], -> Backbone |
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(['data', 'app'], function(data, app) { | |
return app.start(data); | |
}); |
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 Conventions : FubuRegistry | |
{ | |
public Conventions() | |
{ | |
// ... | |
Policies.ConditionallyWrapBehaviorChainsWith<HandledExceptionBehavior>(x => x.BehaviorChain.Last() is JsonSerializer); | |
// ... | |
} | |
} |
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
Assets.Alias("jquery").Is("scripts/jquery/jquery-1.7.1.min.js") | |
.Alias("underscore").Is("scripts/underscore/underscore-min.js") | |
.Alias("backbone").Is("scripts/backbone/backbone-min.js") | |
.AssetSet("default").Is("jquery,underscore,backbone"); |
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.define = function() { | |
var amd = window.amd = window.amd || {}; | |
var scripts = document.getElementsByTagName("script"); | |
var baseUrl; | |
if (!amd.modules) { | |
for (var i = 0; i < scripts.length; i++) { | |
var dataMain = scripts[i].getAttribute('data-base'); | |
if (dataMain) { | |
var a = document.createElement('a'); | |
a.href = dataMain; |