ivaynberg/select2 — pull request #64 by ghing (2012-05-22 16:44:23+00:00)
Title: Check for nonexistent data attribute in a way that works in jQuery 1.4.2

In an app running jQuery 1.4.2, initializing select2 for a select element was failing because of the check for a "select2" data attribute in init()

At least for that version of jQuery, calling .data() with a nonexistent key argument appears to return null. For newer versions of jQuery, it returns undefined.

A simple fix that worked for me was to add a check for opts.element.data("select2") !== null