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
// Solutions to manage the rendered state *better* | |
1. make `rendered` a bool member of `props`. manage rendered bit on your own | |
- weaknesses | |
- it's a pain for the user to have to explicty set `this.rendered` on every render and remove call, despite being a single bit | |
- it get's tricky if you extend muliple view definitions. If you manually set the rendered bit in each child's render function, you get duplicate 'change:rendered' events | |
2. make `rendered` a bool member of `props`. wrap user defined render()s to contain their render() fn AND logic to update `rendered` | |
- weaknesses | |
- again, each version of render() in the proto chain execs the fn and duplicate change events on the `rendered` prop occur |
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
/*global console*/ | |
var SelectView = require('../ampersand-select-view'); | |
var FormView = require('ampersand-form-view'); | |
var Model = require('ampersand-state').extend({ | |
props: { | |
id: 'string', | |
title: 'string' | |
} | |
}); |
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
'use strict'; | |
var Collection = require('ampersand-collection'); | |
var Model = require('ampersand-model'); | |
var MyModel = Model.extend({ | |
props: { | |
field1: 'string', | |
field2: 'string', | |
field3: 'string', | |
field4: 'string', | |
field5: 'string' |
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
'use strict'; | |
// open up your console, follow along | |
// https://github.com/cdaringe/ampersand-webworker-demo/blob/master/index.js | |
require('ampersand-webworker-demo'); |
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
body { | |
font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif; | |
margin: 0; | |
padding: 0; | |
color: #333; | |
background-color: #fff; | |
} | |
div.container { |
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
'use strict'; | |
var Collection = require('ampersand-collection'); | |
// method 1 - basic | |
var parentCollection = new Collection(); | |
var childColl1 = new Collection(); | |
childColl1.set([{id: 1}, {id: 2}]); | |
var childColl2 = new Collection(); |
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
'use strict'; | |
var View = require('ampersand-view'); | |
var view = new View({ | |
template: '<span></span>', | |
el: document.createElement('div') | |
}); | |
if (view.rendered) { | |
alert('view instantiated only, should not be rendered... but i am `rendered`'); |
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.jQuery = require('jquery'); // 2.1.x | |
require('datatables'); // 1.10.6 | |
if (window.jQuery.fn.dataTable) { | |
alert('yahoo!'); | |
} else { | |
alert('bummer :('); | |
} |
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
diff --git a/ampersand-select-view.js b/ampersand-select-view.js | |
index 8b08777..becb863 100644 | |
--- a/ampersand-select-view.js | |
+++ b/ampersand-select-view.js | |
@@ -42,6 +42,7 @@ function SelectView (opts) { | |
this.startingValue = opts.value; | |
this.yieldModel = (opts.yieldModel === false) ? false : true; | |
+ this.eagerValidate = opts.eagerValidate; | |
this.required = opts.required || false; |
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
var State = require('ampersand-state'); | |
var MyState = State.extend({ | |
props: { | |
myDate: { | |
type: 'date', | |
default: null | |
} | |
} | |
}); |