--
You received this message because you are subscribed to the Google Groups "ValidateThis-dev" group.
To post to this group, send email to validate...@googlegroups.com.
To unsubscribe from this group, send email to validatethis-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/validatethis-dev?hl=en.
I do have a proper question for the group... :)
I'm currently doing my best to write jQuery QUnit test for the client
side validation methods.
Firstly, is this a worthwhile exercise for VT (I'm assuming that you
can use cfSelenium to run the QUnit tests and check the result but I
haven't got that far yet).
Secondly, looking at the DoesNotContainOtherProperties method and I
notice that it's checking other properties based on field name (as VT
does), but it's not restricted to the current form. Is this going to
cause problems if users have multiple forms on the page. If so, is it
worth changing it to use the id of field instead.
So, instead of:
var propertyValue = jQuery(':input[name='+this+']').getValue();
use:
var propertyValue = jQuery('#'+this+']').getValue();
Thanks,
- John
@Dan - I'm not getting much sense from myself either!
I do have a proper question for the group... :)
I'm currently doing my best to write jQuery QUnit test for the client
side validation methods.
Firstly, is this a worthwhile exercise for VT (I'm assuming that you
can use cfSelenium to run the QUnit tests and check the result but I
haven't got that far yet).
Secondly, looking at the DoesNotContainOtherProperties method and I
notice that it's checking other properties based on field name (as VT
does), but it's not restricted to the current form. Is this going to
cause problems if users have multiple forms on the page. If so, is it
worth changing it to use the id of field instead.
So, instead of:
var propertyValue = jQuery(':input[name='+this+']').getValue();
use:
var propertyValue = jQuery('#'+this+']').getValue();
> I am not familiar with QUnit. Right now I'm just doing straight Selenium
> tests using CFSelenium to test out each of the built-in client-side
> validations. If there is a nice way to do this as a straight Javascript
> test, rather than using Selenium I can see value in that. I guess I need to
> understand how QUnit works and what it's relationship to Selenium is to know
> whether it's a better approach than what I'm doing now. Maybe we can chat
> about that sometime soon.
QUnit produces a green/red report in the browser. Here's an example:
http://docs.jquery.com/Qunit
If you want to try it out, the jQuery validate plugin has numerous
QUnit tests if you download it and look in the tests directory.
>
> I haven't looked at the code for this yet, but I know that for some of the
> client-side stuff it's written to address the issue of multiple forms. It
> locates DOM elements by specifying the form on which they should appear. Can
> we take that same approach with this, to be consistent? Or is there a reason
> that won't work in this case?
> Thanks,
> Bob
I might be being dumb, but as these are the generic validation methods
I don't see how you could bind it to a form. You could change the way
the method works so you can pass in a selector of '#myform
:input[name=foo]', which means that the developer is responsible for
binding to the form. This will break existing code though... Thinking
about it a bit more I suppose I could get the element being validated
and derive the form it's in from that and restrict the other
properties selector to the validated elements form, that might
work....
Thanks Bob.
QUnit produces a green/red report in the browser. Here's an example:
> I am not familiar with QUnit. Right now I'm just doing straight Selenium
> tests using CFSelenium to test out each of the built-in client-side
> validations. If there is a nice way to do this as a straight Javascript
> test, rather than using Selenium I can see value in that. I guess I need to
> understand how QUnit works and what it's relationship to Selenium is to know
> whether it's a better approach than what I'm doing now. Maybe we can chat
> about that sometime soon.
http://docs.jquery.com/Qunit
If you want to try it out, the jQuery validate plugin has numerous
QUnit tests if you download it and look in the tests directory.
>I might be being dumb, but as these are the generic validation methods
> I haven't looked at the code for this yet, but I know that for some of the
> client-side stuff it's written to address the issue of multiple forms. It
> locates DOM elements by specifying the form on which they should appear. Can
> we take that same approach with this, to be consistent? Or is there a reason
> that won't work in this case?
> Thanks,
> Bob
I don't see how you could bind it to a form. You could change the way
the method works so you can pass in a selector of '#myform
:input[name=foo]', which means that the developer is responsible for
binding to the form. This will break existing code though... Thinking
about it a bit more I suppose I could get the element being validated
and derive the form it's in from that and restrict the other
properties selector to the validated elements form, that might
work....
--
You received this message because you are subscribed to the Google Groups "ValidateThis-dev" group.
To post to this group, send email to validate...@googlegroups.com.
To unsubscribe from this group, send email to validatethis-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/validatethis-dev?hl=en.
Thanks for looking - I'll have to grab a copy of what's in the github
branch and see if I can replicate that error when I can 5 mins spare.
I've attached the sourcecode from the FacadeDemo in my local repo.
Cheers,
- John
Thanks for looking at this and your suggestions. Until now, I've not
really been worrying about saving a few bytes, but I'm happy to review
that as well if you think it's worthwhile. There are quite of lot of
places where you could save the odd byte.
I'll definitely sort out the namespacing, I should have thought of
that originally.
Thanks again,
- John
Do you guys think that this is worthwhile as you're loosing some
readability in the generated JS?
P.S. I could save a few extra bytes by removing the Copyright notice
on the jQuery Field Plug-in :)