-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"toString" the value of an object #6
Comments
I am not sure what you mean, in json ther eis nothing like "toString" or a value of an object. if you have an object like then "what" would be the result of "toString" (if something like that exists). In addition, "toString" is not reversible. so if even if you would have something like toString and would write an object containing multiple fields into a textara (which can hold only strings) - what would be the reverse? However, there is a "workaround" that I use form time to time. For example i have an object like this: and i want to display the "displayname" (which is either the fullname or the name + lastname), then i create a preprocess function (i use it mostly to display infos) ´´´ if(obj.fullname && obj.fullname !== '') obj.displayname = obj.fullname; $("#myform").jsForm("fill", obj); this would a field that is filled I hope this informatio helps |
Sorry, my example is at http://jsfiddle.net/Mattes/AbwGC/1/ What I mean is JSON.stringify ... of course .. I need a field where the user can insert "anything" (of course valid json) ....but I will try the "preprocessing" Thanks |
Hmm.. now i see what you mean. Following suggestion: When "get"ting the form, it will look for the bound object. Let me update the script real quick and i can add a smaple for you |
You are fantastic! (I told you already 👍 ) |
so.. in theory the last commit should do it. I made sure that the object is correctly bound on the input (if you specify class="object") -> it uses $(input).data("pojo"). it will also read from that when constructing the json for "get"! the change event was already triggered, but i also added a "fill" event ( i will deprecate the change event in the future). I also commited your jsfiddle sample - and extended it a little to show writing as well. Hope this works for you. |
Is it possible to "render" the value of an object in a textarea?
Something like a toString
I made an example at http://jsfiddle.net/Mattes/AbwGC/
The text was updated successfully, but these errors were encountered: