| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>MVC DOH Test</title> |
| 6 |
<style> |
| 7 |
@import "../../../../dojo/resources/dojo.css"; |
| 8 |
</style> |
| 9 |
|
| 10 |
<script src="../../../../dojo/dojo.js" type="text/javascript" data-dojo-config="isDebug: 1, parseOnLoad: 0, async: 1, mvc: {debugBindings: true, extensionPerWidget: true}"></script> |
| 11 |
<script type="text/javascript" src="./helpers.js"></script> |
| 12 |
<script type="text/javascript"> |
| 13 |
require([ |
| 14 |
"doh/runner", |
| 15 |
"dojo/dom", |
| 16 |
"dojo/Stateful", |
| 17 |
"dijit/_WidgetBase", |
| 18 |
"dijit/form/TextBox", |
| 19 |
"dojox/mvc/at", |
| 20 |
"dojox/mvc/atBindingExtension" |
| 21 |
], function(doh, dom, Stateful, _WidgetBase, TextBox, at, atBindingExtension){ |
| 22 |
doh.register("doh_mvc_extension-per-widget", [ |
| 23 |
function widgetNotExtended(){ |
| 24 |
var model = new Stateful({value: "Foo"}), |
| 25 |
w = new TextBox({value: at(model, "value")}, dom.byId("tb0")); |
| 26 |
w.startup(); |
| 27 |
doh.f(w.value == "Foo", "Widget should not have been looked at at()"); |
| 28 |
}, |
| 29 |
function extendInstance(){ |
| 30 |
var model = new Stateful({value: "Foo"}), |
| 31 |
w = atBindingExtension(new TextBox({}, dom.byId("tb1")))[0]; |
| 32 |
w.startup(); |
| 33 |
w.set("value", at(model, "value")); |
| 34 |
doh.is("Foo", w.value, "Extended widget should have been initialized with the model value"); |
| 35 |
model.set("value", "Bar"); |
| 36 |
doh.is("Bar", w.value, "Extended widget should have been updated with the model value"); |
| 37 |
w = new TextBox({value: at(model, "value")}, dom.byId("tb2")); |
| 38 |
w.startup(); |
| 39 |
doh.f(w.value == "Bar", "Non-extended widget should not have been looked at at()"); |
| 40 |
}, |
| 41 |
function extendClass(){ |
| 42 |
atBindingExtension(TextBox.prototype); |
| 43 |
var model = new Stateful({value: "Foo"}), |
| 44 |
w = new TextBox({value: at(model, "value")}, dom.byId("tb3")); |
| 45 |
w.startup(); |
| 46 |
doh.is("Foo", w.value, "Extended widget should have been looked at at()"); |
| 47 |
w = new _WidgetBase({value: at(model, "value")}, dom.byId("w0")); |
| 48 |
w.startup(); |
| 49 |
doh.f(w.value == "Foo", "Non-extended widget should not have been looked at at()"); |
| 50 |
} |
| 51 |
]); |
| 52 |
|
| 53 |
doh.run(); |
| 54 |
}); |
| 55 |
</script> |
| 56 |
</head> |
| 57 |
<body> |
| 58 |
<input id="tb0" type="text"> |
| 59 |
<input id="tb1" type="text"> |
| 60 |
<input id="tb2" type="text"> |
| 61 |
<input id="tb3" type="text"> |
| 62 |
<span id="w0"></span> |
| 63 |
</body> |
| 64 |
</html> |