Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added access to elements that observable is bound to and some events V1.0 #29

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

kmanpro
Copy link

@kmanpro kmanpro commented Feb 28, 2012

I forgot to say in my first request, great work! I love this extension for knockout!

Here is one based on v1.0. I closed the other pull request.

I made this change to be able to access the element(s) that the observable is bound to so I can use qtip to display the messages on validation error instead of inserting it right next to it.

The events are needed so I can fire off a function when it is all done, onValidationStart and onValidationError.

If you have any questions or better ways of implementing let me know. Or if you don't feel comfortable pulling this in I understand. Just though it might be useful to some as it was to me.

Thanks!
Kaleb

Also adding an array of elements on each observable so we can tell what elements if any that this observable is bound on. This is useful so we can hook into a validation error later and use an external lib like qtip to display the error messages instead of just inserting a span into the html.
… calling the onValidationStart event correctly
@ericmbarnard
Copy link
Member

@kmanpro

Ok - I'm really sorry for the delay on getting to this - we've had some projects at work that I haven't been able to peel away from.

A couple thoughts-

  • It seems your event onValidationStart and onValidationEnd get called whenever a bindingHandler or function that might perform validation fire. I assume this is what you want, but in some cases the even would be raised multiple times should an observable have a couple of these bindings attached to it.
  • I'm not sure how I feel about keeping an elements array on the observable. KO itself has the purpose of keeping your viewmodels disconnected from the DOM, and thus carrying around those element pointers on the observable would add a bit of unnecessary weight.

Is your main purpose here to meet your needs with QTip? If so, I'll try to take stab at a suggested strategy for that.

…he observable but instead using the validationElement binding to fire off an event that I can hook into with qTip and display the messages.
@ericmbarnard
Copy link
Member

@hfjallemark

Thanks for that - the rules fix is now in latest commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants