Occurs when an item is added, removed, changed, moved, or the entire list is refreshed.
Object.defineProperty(LeadCollection.prototype,'collectionChanged',
get: function(),
set: function(value)
)
function collectionChanged.add(function(sender, e));
function collectionChanged.remove(function(sender, e));
collectionChanged: void;
Parameter | Type | Description |
---|---|---|
sender | var | The source of the event. |
e | NotifyLeadCollectionChangedEventArgs | The event data. |
See NotifyLeadCollectionChangedEventArgs for more information on the content of changes.
When checking for changes in CollectionChanged, it is better practice to check the values of NotifyLeadCollectionChangedEventArgs.OldItems and NotifyLeadCollectionChangedEventArgs.NewItems than NotifyLeadCollectionChangedEventArgs.Action, to prevent cases where a NotifyLeadCollectionChangedAction case is missed or incorrectly handled. See below for an example:
`
function collectionChanged(sender, args) {
// Optionally, surround the code below in an if-statement like:
// if (args.action !== lt.NotifyLeadCollectionChangedAction.move) { ... }
// since sometimes we don't need to do anything if the item is removed
// and then added back in a different spot.
// Check for removed items first to do some clean-up
if (args.oldItems.length > 0) {
// Do some setup, if necessary...
// Loop and do work
for (var i = 0; i < args.oldItems.length; i++) {
doRemovedItem(args.oldItems[i]);
}
}
// Now check for added items
if (args.newItems.length > 0) {
// Do some setup, if necessary...
// Loop and do work
for (var i = 0; i < args.newItems.length; i++) {
doAddedItem(args.newItems[i]);
}
}
}