Testing if the object exists before use it

It's necessary to make the code compatible with IE8 and IE9.
Merge pull request #2720 from josmardias/fix-ie8-ie9

Fixing IE8 and IE9 issues on select2#3.5.1