ivaynberg/select2 — pull request #2691 by backnight (2014-09-19 01:25:29+00:00)
Title: Added element param to formatResult and createSearchChoice function

I added the element to formatResult and createSearchChoice function to have more flexibility.

For example, if I want to create a new result on the fly via createSearchChoice function, I need to access my "element" which has some useful data/configuration settings in its attributes (like the url to call via ajax, etc).

I did the same to formatResult because sometimes I don't want to create a new result (in database) when createSearchChoice is called BUT ONLY when this "new result" is selected (createSearchChoice returns a new result with an ID = -1 and then formatResult catch it, check if it equal to -1 and then send the ajax request to create the new result in database).