gwendall / way.js

Simple, lightweight, persistent two-way databinding
2.87k stars 254 forks source link

null appearing in text fields #59

Open Ataye opened 9 years ago

Ataye commented 9 years ago

I have some props in my object that are string (in the json text string) but type being reported as object. and contain null values. When bound to a textbox the word 'null' appears. Shouldn't it handle this and instead use an empty string when binding with textboxes?

I got around this by cleaning up the object prior to loading it into way.js using (jquery):

for (var property in obj) {
if (obj.hasOwnProperty(property) && $.isEmptyObject(obj[property]))
   obj[property] = '';
}
way.set("scope", obj);

I'm coming from angular data-binding and wanted a lightweight data-binding solution for my non-angular projects and this is exactly what i needed. Great work!