Using knockout, I need to reset certain templates, not the entire form. resetForm()
resets everything. Anyone ran across this before?
I\'ve looked at this
I'm working on a project with knockout and jquery validate at the moment. One thing I've settled upon is dividing the user input into subsections, essentially having multiple forms on the same page. Combine them all together and that's the total 'form' the user sees.
(Aside: I'm doing this because the API I'm submitting to has different expectations from what the form/UI/marketing dept. expects of the user experience. Each <form>
is essentially a different API input section, but the marketing dept wanted to be able to order the user inputs arbitrarily, so I'm gathering them up by class:
<form class="api1">
... some inputs
</form>
<form class="api2">
... some different inputs
</form>
<form class="api1">
... some more inputs
</form>
I'm submitting these by Ajax (it's a single page app), so I'm not really losing anything from the standard form/action/submit/post model by doing this. But applying this to your situation, you could then essentially go:
$("#sectionId form.api1").each(function() {
$(this).validate().reset();
});
I may have gotten that syntax wrong, I'm not using the reset function on jQuery validate. But now that I think about it, I probably could save some code if I did...
Feel free to post some code and I can better adapt my solution to your problem.