This file contains 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
can.Application.extend({ | |
template: can.view('index.stache'), | |
content: '#content', | |
state: { | |
}, | |
routes: { | |
empty: function(data) { |
This file contains 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
- 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. |
This file contains 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
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); | |
} | |
}); |