Page 2 of 2

How to catch an error if a field is empty in an array

Posted: Tue Jul 29, 2014 11:13 pm
by Yurii Orishchuk

Hi Anil,

Your problem is just you get only first item with code:

pre

//It's necessery to understand that's this code returns only first item with name "Offer_image".
//This code works globaly for all document. And here is no linking to current element
Apperyio("Offer_image");

/pre

Please use following solution to get it work:

1 Open your mapping.

2 Find "mobilegrid_1" component and click "Edit JS". http://prntscr.com/47n441/direct

3 JS editor will appear. Populate it with following code:

pre

//Note "files/resources/image/no-image.jpg" is default image. You can replace it with your default image url.
var src = value.image ? Appery.getImagePath(value.image) : "files/resources/image/no-image.jpg";
element.find('[name="Offer_image"]').attr("src", src);

return value;

/pre

That's all.

Regards.


How to catch an error if a field is empty in an array

Posted: Wed Jul 30, 2014 2:43 am
by Anil Sagar

Many thanks Yuri. This works.