getting events from subschemas

160 views
Skip to first unread message

dot Config

unread,
Feb 12, 2013, 7:02:16 PM2/12/13
to backbon...@googlegroups.com
spent a ton of time trying to get this to work... followed this example with modifications i made...

var MyForm = new Backbone.Form({
    schema: {
        title:      { type: 'Select', options: ['Mr', 'Mrs', 'Ms'] },
        name:       'Text',
        email:      { validators: ['required', 'email'] },
        address: { type: 'List', itemType: 'Object', 
            subSchema: {
                street: { type: 'Text' },
                zip: { type: 'Number' },
                country: { 'Select', options: ['USA', 'UK'] }
        }}
});

MyForm.on('name:change', function(form, nameEditor) {
   console.log(nameEditor.getValue());  // works!
});

MyForm.on('zip:change', function(form, zipEditor) {
    console.log('Zip changed to "' + zipEditor.getValue() + '".');  // does not work!
});

how do i get events from the subschema in the main code?


thanks!

Charles Davison

unread,
Feb 21, 2013, 4:32:09 AM2/21/13
to backbon...@googlegroups.com
You should be able to do this:

You can use dot notation e.g. : 'address.zip'



--
You received this message because you are subscribed to the Google Groups "Backbone-forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to backbone-form...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Austin Bloom

unread,
Mar 19, 2013, 4:35:14 PM3/19/13
to backbon...@googlegroups.com
I'm having the same problem and I've tried using the dot notation. Any advice?

Thanks!

-Austin
Message has been deleted
Message has been deleted

Adrien Grsmto

unread,
Apr 2, 2014, 7:41:41 AM4/2/14
to backbon...@googlegroups.com
To get events from a subschema you have to listen to it only when the sub form is created. With your example :

this.form.fields.address.editor.on('item:open', function(listEditor, itemEditor) {
    itemEditor.modalForm.fields.zip.editor.on('change', function(itemEditor) {
         console.log(itemEditor.getValue());
    });
});
Reply all
Reply to author
Forward
0 new messages