Skip to content
Browse files

Support other types of bindable things in object children

  • Loading branch information...
1 parent 7d4bc8e commit 961b65b1178faf5188f2e695958c46590b55a166 @kriszyp committed Oct 11, 2012
Showing with 8 additions and 8 deletions.
  1. +2 −3 bind.js
  2. +6 −5 tests/testStateful.js
View
5 bind.js
@@ -35,9 +35,8 @@ define([], function(){
// use an existing child/property if it exists
var value, child = this['_' + key] ||
(this['_' + key] = this.hasOwnProperty("value") && typeof this.value == "object" ?
- (value = this.value[key]) && value.get ? new StatefulBinding(value) :
- new PropertyBinding(this.value, key) :
- new Binding());
+ (value = this.value[key]) && typeof value != "object" ? new PropertyBinding(this.value, key) :
+ convertToBindable(value) : new Binding());
if(callback){
return child.then(callback);
}
View
11 tests/testStateful.js
@@ -1,4 +1,4 @@
-define(['dbind/bind', 'dojo/Stateful', 'dijit/form/TextBox'], function(bind, Stateful, TextBox){
+define(['dbind/bind', 'dojo/Stateful', 'dojo/dom-construct', 'dijit/form/TextBox'], function(bind, Stateful, domConstruct, TextBox){
function Model(props) {
var stateful = new Stateful(props),
first = bind(stateful, 'first'),
@@ -19,10 +19,11 @@ define(['dbind/bind', 'dojo/Stateful', 'dijit/form/TextBox'], function(bind, Sta
last: 'last'
});
console.log(model);
- var viewModel = {
- last: new TextBox().placeAt('content')
- };
-
+ var viewModel = {
+ first: new TextBox().placeAt('content'),
+ last: new TextBox().placeAt('content'),
+ fullName: domConstruct.create('div', null, 'content')
+ };
bind(viewModel).to(model);
model.set("first", "John");

0 comments on commit 961b65b

Please sign in to comment.
Something went wrong with that request. Please try again.