1
0
mirror of synced 2024-11-26 23:06:02 +03:00

Avoid error when label has no matching element

$('#no_such_element').data("select2") returns null rather than
undefined (jQuery 1.9.0).
This commit is contained in:
Ronald J Kimball 2013-01-23 13:53:15 -05:00
parent 4e92c8b1b4
commit 7ec1e753dc

View File

@ -529,7 +529,7 @@ the specific language governing permissions and limitations under the Apache Lic
attr = attr.replace(/([\[\].])/g,'\\$1'); /* escapes [, ], and . so properly selects the id */ attr = attr.replace(/([\[\].])/g,'\\$1'); /* escapes [, ], and . so properly selects the id */
target = $("#"+attr); target = $("#"+attr);
target = target.data("select2"); target = target.data("select2");
if (target !== undefined) { target.focus(); e.preventDefault();} if (target !== undefined && target !== null) { target.focus(); e.preventDefault();}
} }
}); });
}); });