Skip to content

Instantly share code, notes, and snippets.

@daffl
daffl / application.js
Created June 12, 2014 18:59
can.Application concept
can.Application.extend({
template: can.view('index.stache'),
content: '#content',
state: {
},
routes: {
empty: function(data) {
@andrewk
andrewk / Nested DOM structure as FlightJS components
Last active August 29, 2015 13:59
Response to request for modelling nested DOM as flight components - https://gist.github.com/djreimer/10687904
- I wrote this on the train after a long day with a heavy head cold. I haven't run it,
but regardless of likely errors I think it expresses the design well enough.
- Segment and ConditionSet look close to identical, but that's likely due to the simplified
nature of the outline you provided
- I don't like attaching components to classes unless they're `js-`, as it's coupling
your styling and behaviour layers. We excelusively use data attributes for JS-DOM coupling
and I've quickly grown fond of the approach.
@daffl
daffl / can-jquery-model-json.js
Created February 28, 2014 17:24
A prefilter that allows to send your CanJS model as JSON
can.ajaxPrefilter(function(options, originalOptions) {
// Change ContentType to application/json for POST and PUT
if(options.processData && !(/^application\/json((\+|;).+)?$/i.test(options.contentType)) && /^(post|put|delete)$/i.test(options.type)) {
options.contentType = "application/json";
options.data = JSON.stringify(originalOptions.data);
}
});