[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    Re: Tapestry-jquery ajax validation
From:       rosecorp <rosecorp.solutions () gmail ! com>
Date:       2012-12-25 16:50:44
Message-ID: 1356454244836-5718980.post () n5 ! nabble ! com
[Download RAW message or body]

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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic