I need to validate in asset dam properties.
I took reference from https://helpx.adobe.com/experience-manager/using/creating-touchui-validate.html
Code Snippet -
$(document).on("click", ".aem-assets-admin-properties-submit", function (e) {
e.stopPropagation();
e.preventDefault();
ddlOrderValue = $("#ddlChar option:selected").val();
if(typeof ddlOrderValue == "string" && typeof primaryBVTag == "string" && typeof primarySLTag == "string"){
var ddlOrderValueCheck = ddlOrderValue.substring(ddlOrderValue.lastIndexOf("/")+1);
var primaryBVTagCheck = primaryBVTag.substring(primaryBVTag.lastIndexOf("/")+1);
var primarySLTagCheck = primarySLTag.substring(primarySLTag.lastIndexOf("/")+1);
}
if( (($('#setcontentownerid').hasClass("hide")) == false ) && (ddlOrderValueCheck == '') || ( primaryBVTagCheck == '' && primarySLTagCheck == '') || ((ddlOrderValueCheck != primaryBVTagCheck) && (ddlOrderValueCheck != primarySLTagCheck)) ) {
alert("Check your Inputs");
ns.ui.helpers.prompt({
title: Granite.I18n.get("Invalid Input"),
message: "Please Enter valid Inputs",
actions: [{
id: "CANCEL",
text: "CANCEL",
className: "coral-Button"
}],
callback: function (actionId) {
if (actionId === "CANCEL") {
}
}
});
}else{
alert("else");
createNewTags($(".data-fields.active form")).done(function(){
var form = $('.data-fields.active form');
alert("else aem-submit -createNewTags");
handleResponse(form, submitForm(form));
}).fail(function(response){
var modal = $('#aem-assets-metadataedit-error');
var body = Granite.I18n.get('Unable to create new tags. Check for access privileges to create tags.');
modal.find(".coral-Modal-body").html('<p>' + body + '</p>');
modal.modal("show");
});
alert("end of else");
}
});
// -----------------------------------------------------------------------------------------------------------------------
function createNewTags (form) {
return $.when.apply(null, form.find('[data-metatype="tags"].coral-PathBrowser+ul.coral-TagList input[type="hidden"][name]').map(function() {
var el = this;
if (el.value.indexOf(":") >= 0) return;
var tenantId = $(".foundation-form.mode-edit").attr("tenant-id");
el.value = tenantId ? ("mac:" + tenantId + "/default/" + el.previousElementSibling.textContent ) : el.previousElementSibling.textContent;
return createSingleTag(el.value).then(function(tag) {
// Fix tag name in select element
var tenantId = $(".foundation-form.mode-edit").attr("tenant-id");
if (!tenantId) {
// Fix tag name in select element
el.value = tag;
}
});
}));
}
I am getting error because of ns.ui.helper.prompt({ }); , error in browser console is -
Uncaught TypeError: Cannot read property 'ui' of undefined
at HTMLButtonElement.<anonymous> (clientlib-assetspropertiesdialog.js:287)
at HTMLDocument.dispatch (jquery.js:4665)
at HTMLDocument.elemData.handle (jquery.js:4333)
Views
Replies
Total Likes
Hi
Moving this post to AEM "Assets" topic so that contextual experts can help you.
~kautuk
Views
Replies
Total Likes
The article you mentioned is about how to validate fields in a component dialog. Has nothing to do with Assets.
Views
Replies
Total Likes
Can you make sure "ns" is defined? Or can you share the complete code?
Views
Replies
Total Likes
please mention aem version
Views
Replies
Total Likes
Views
Likes
Replies