Handling the case when closing MediaLibraryPickerField dialog without having selected anything to prevent a null reference javascript error.

--HG--
branch : 1.x
This commit is contained in:
Sipke Schoorstra
2013-04-27 22:48:12 +02:00
parent 64525b2f82
commit 6bfa77bb76

View File

@@ -92,6 +92,10 @@
$('html, body').css('overflow', ''); $('html, body').css('overflow', '');
var selectedData = $.colorbox.selectedData; var selectedData = $.colorbox.selectedData;
if (selectedData == null) // Dialog cancelled, do nothing
return;
for (var i = 0; i < selectedData.length; i++) { for (var i = 0; i < selectedData.length; i++) {
var template = @Html.FieldIdFor(m => m.Field.Ids)_Template.replace(/\{contentItemId\}/g, selectedData[i].id).replace(/\{thumbnail\}/g, selectedData[i].thumbnail).replace(/\{title\}/g, selectedData[i].title); var template = @Html.FieldIdFor(m => m.Field.Ids)_Template.replace(/\{contentItemId\}/g, selectedData[i].id).replace(/\{thumbnail\}/g, selectedData[i].thumbnail).replace(/\{title\}/g, selectedData[i].title);