Im trying to uncheck a checkbox in the ComponentView of Tridion by jquery using the document ready event in a GUI extension:
$j(document).ready(function(){
alert("is loaded");
var field = $j('[type=checkbox][value=Aceptar]')
field.attr("checked",false);
console.log("field = " + field.is(':checked'));
alert("is checked field = " + field.is(':checked'));
});
The problem is that on "$j(document).ready" the field values don't seem to be loaded in the ComponentView. My alert returns that the field is unchecked, but when the view finishes loading the checkbox is checked.It seems that the "$j(document).ready" fires before the values are loaded. Does anybody know which event I should use?
@Adrian Salazar @Sogo Thanks for your help, maybe I should use better "prop" instead of "attr" to change that property, but the problem was the same, the fields weren't still loaded so I couldn't change that property.
@Frank I tried with "$evt.addEventHandler($display, "start", onDisplayStarted);" on the "ComponentView" display, and extending that view on the configuration of my GUI extension, but on that event the fields are still not loaded also, and everytime I tried to access my checkbox field it said that was "undefined".
Finally I managed to uncheck the checkbox suscribing to the load event of the component :
"EventSystem.Subscribe <Component, LoadEventArgs> (OnComponentLoad, EventPhases.Processed);"
as Nuno explains here http://www.tridiondeveloper.com/inheriting-metadata-on-organizational-items#more-1073, he uses it on an OrganizationalItem but works the same for a component.
Thanks for your help!!