I am doing some custom field level validation in touch UI. I can see the dialog-ready and
(function(document, $) {
"use strict";
$(document).on("change", ".nutri-info-content", function(e) {
var val = $(".nutri-info-dropdown").val(); // This works
if (val == "abc") {
$('.nutri-info-field').parent().hide();
}
});
$(document).on("foundation-contentloaded", function(e) {
var val = $(".nutri-info-dropdown").val(); // Value is not coming. facing same problem even with dialog-ready event.
if (val == "abc") {
$('.nutri-info-field').parent().hide();
}
});
})(document, Granite.$);
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
The events do work, could you please share your dialog xml?
(function(document, $) {
"use strict";
$(document).on("foundation-contentloaded", function(e) {
var item = $(".nutri-info-dropdown").val(); // Value is not coming. facing same problem even with dialog-ready event.
console.log(item);
});
$(document).on("change", ".nutri-info-dropdown", function(e) {
var item = $(".nutri-info-dropdown").val(); // This works
console.log(item);
});
})(document, Granite.$);
Hi @Anderson_Hamer,
You can use dialog-ready for code to trigger once the dialog is fully loaded and dialog-closed to trigger a code once the dialog is closed.
Check the code in the question in the below URL:
Hope this helps!
Thanks,
Kiran Vedantam.
Views
Replies
Total Likes
The events do work, could you please share your dialog xml?
(function(document, $) {
"use strict";
$(document).on("foundation-contentloaded", function(e) {
var item = $(".nutri-info-dropdown").val(); // Value is not coming. facing same problem even with dialog-ready event.
console.log(item);
});
$(document).on("change", ".nutri-info-dropdown", function(e) {
var item = $(".nutri-info-dropdown").val(); // This works
console.log(item);
});
})(document, Granite.$);
The OP is right, the foundation-contentloaded event fires before the form fields are assigned their values, the event should fire only after the javascript is done assigning the values to all the dialog fields.
It's even more strange: Apparently there are multiple locations where foundation-contentloaded gets triggered. It doesn't only trigger for dialogs. Some examples:
* When clicking add / remove item on a multifield, the foundation-contentloaded gets triggered for the multifield
* When loading editor.html, I also see foundation-contentloaded get triggered multiple times, on document and also once for a random div.
There seems to be no real consistency in this; I.e. there is no nice way to handle dialog load in a simple way.
Views
Replies
Total Likes