Timing Issue

Apr 3, 2009 at 8:26 PM
I am having a timing issue with the 0.8 Beta versoin of xVal and jQuery 1.3.2. I modified the _attachRuleToDOMElement method of the .js file to add a css class, "required" (element.addClass("required")), to all input fields that have the required rule. Then in my jQuery .ready function I have the following code to append an asterisk to the label for these input fields. It works well in jQuery 1.2.6 but does not for 1.3.2. In jQuery 1.2.6, all labels for required fields receive the asterisk. In 1.3.2, only the first item get the asterisk and the $required variable only has the first element that has a css class="required".

It appears that the .ready function is called in 1.3.2 before the validation rules are finished being applied. I do not know whether this is a problem with the validation script or jQuery 1.3.2. I have also posted this question on the jQuery [English] group.

This works really slick in 1.2.6 and is a way to have the model business rules drive the UI. All I need to do is add a required attribute on the property in my buddy class and the element label automatically gets an asterisk indicating to the user that it is a required field. But I would like for it to work in jQuery 1.3.2 as well.

$(document).ready(function() {
           $required = $(".required"); // list of elements with 'required' class.
           $.each($required, function(i) {
               var id = $(this).attr('id');
               var $label = $("label[for=" + id + "]");
               //$label.text($label.text() + '*');
               $label.append('&nbsp;<span class="required_field">*</span>&nbsp;');


Apr 8, 2009 at 3:14 AM
This appears to be fixed by changeset 14809.