replace
	
	
		can.List.prototype.replace
	
	
	
	 
Replace all the elements of a List.
list.replace(collection)
Parameters
- 
			
collection
{Array | can.List | can.Deferred}the collection of new elements to use If a can.Deferred is passed, it must resolve to an
Arrayorcan.List. The elements of the list are not actually removed until the Deferred resolves. 
replacereplaces all the elements of this List with new ones.replaceis especially useful whencan.Lists are live-bound intocan.Controls, and you intend to populate them with the results of acan.Modelcall:Learn more about making Lists of models.
Events
A major difference between
replaceandattr(newElements, true)is thatreplacealways emits an add event and a remove event, whereasattrwill cause set events along with an add or remove event if needed. Corresponding change and length events will be fired as well.The differences in the events fired by
attrandreplaceare demonstrated concretely by this example: