chap3 -> Creating a binding to debug - the toJSON binding
parent
f6a61ea524
commit
be3a58c325
|
@ -19,6 +19,7 @@
|
|||
</div>
|
||||
<div data-bind="template: {name:'add-to-catalog-modal'}"></div>
|
||||
<div data-bind="template: {name:'finish-order-modal'}"></div>
|
||||
<pre class="well well-lg" data-bind="toJSON: $root"></pre>
|
||||
</div>
|
||||
|
||||
<!-- vendor library -->
|
||||
|
|
|
@ -23,3 +23,11 @@ ko.bindingHandlers.currency = {
|
|||
});
|
||||
},
|
||||
};
|
||||
|
||||
ko.bindingHandlers.toJSON = {
|
||||
update: function (element, valueAccessor) {
|
||||
return ko.bindingHandlers.text.update(element, function () {
|
||||
return ko.toJSON(valueAccessor(), null, 2);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue