I don’t think I words explain it better than the code below.
Here’s the collection program (CollectionFactory.utils.js file):
[updated with a jQuery event trigger method]
A System-User super class (SysUser.model.js file):
A Customer class derived from System-User (Customer.model.js file):
And finally the CustomerCollectionFactory singleton implementation that will return new CollectionFactory object (CustomerCollectionFactory.utils.js file)
Now to demonstrate the usage; suppose you are making an AJAX call and retreiving a bunch of “customer” objects (I’m assuming JSON return) displaying them in a master-grid and and making edits to them in a dependant form. You need a central store something like an ArrayCollection in Flex with bindings to the Grid and Form.
You’d use the collection as shown in the code below:
Now when you click the “delete” button on your grid all you have to do is:
To enable the binding, you can bubble the “collection_changed” event upto the document
Hope this helps someone….