Sure.
Js function shoul look like:

(function($) {
    $.fn.configureValidators = function(callbackUrl) {
                $(this.selector).blur(function() {
                        var field = $(this);
                        if (field && field.val() != "") {
                                $.ajax({
                                        url:callbackUrl,
                                        type:'post',
                                        async : false,
                                        data:{
                                                value: field.val(),
                                                id: $(field).attr('id')
                                        },
                                        success: function(response) {
                                                if(response != "") {
                                                        
$(field).one(Tapestry.FIELD_VALIDATE_EVENT, function(e, data,
translated) {
                                                        
$(field).tapestryFieldEventManager("showValidationMessage",response);
                                                        });
                                                }                               
                
                                        }                                       
                                });                             
                        }
                });
    };
    
})(jQuery);


Important thing is to execute one function instead of on this will allow
validation still working. 

Java code look like:

@Import(library = "AjaxValidator.js")
public class AjaxValidator {

        public static final String AJAX_VALIDATE = "AJAX_VALIDATE";
                
        @Inject
        private ComponentResources componentResources;
        
        @Environmental
        private JavaScriptSupport javaScriptSupport;

        /**
         * The element we attach ourselves to
         */
        @InjectContainer
        private ClientElement clientElement;
        
        @AfterRender
        public void afterRender() {
                String clientId = clientElement.getClientId();
                Link link = componentResources.createEventLink(AJAX_VALIDATE, 
clientId);
                
javaScriptSupport.addScript("$('#%s').configureValidators('%s')",
clientId, link.toURI());
        }
}

Thanks,
R



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Tapestry-jquery-ajax-validation-tp5718946p5718980.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to