Modifying view format on the fly

38 views
Skip to first unread message

Noel da Costa

unread,
Jun 7, 2013, 3:20:13 AM6/7/13
to agil...@googlegroups.com
Is there any way to modify the format with new bindings after data is loaded?
 

I found this, which is cool: https://github.com/jonathaneunice/agility/commit/f392e87fab2ce954c2d4c32c7655e6915276dbdf

I can't figure out how to use it though... does anyone have an example?

Specifically what I'm trying to do is to use a different template (i.e. format) depending upon what data comes back. So for example, I'm presenting a form but rather than create a different form for each model, what I want to do is have the form build itself depending on the type of data. So the json data I'm fetching will be something like this:

{"id":{"value":"1","type":"disabled","class":"disabled"},"name":{"value":"My Company","type":"text","tag":"input","class":"text","validation":"text,required"}}

From that I want to build the form dynamically so that it will pull in an input element for text fields and checkboxes for checkboxes, without me having to build each form as a template.

I've tried updating the view from the "create" event in the controller but any data-binding in the appended HTML is ignored. I thought view.sync() would sort that but I obviously don't understand the purpose of view.sync().
 
Reply all
Reply to author
Forward
0 new messages