2016-12-12 2 views
2

"vc.resetValidation는 함수가 아닙니다." 양식이 효과적으로 제출됩니다 - 업데이트가 잘 이루어졌습니다. 어떻게이 오류를 해결할 수 있습니까? 여기 자동 폼 업데이트 : 나는 사용자의 스키마에 대한 양식을 업데이트 할 때 오류 <code>vc.resetValidation is not a function</code>를 얻을 내가</p> <pre><code>aldeed:collection2-core aldeed:autoform aldeed:schema-deny npm simpl-schema </code></pre> <p>에있어

은 여기 내 쿼리

{{#autoForm collection='Meteor.users' doc=currentUser type='update' id='accountForm'}} 
{{> afFieldInput name='profile.phone'}} 
{{> afFieldInput name='profile.avatar'}} 
<button type='submit' class="at-btn dark">Update</button> 
{{/autoForm}} 

이다 나는 당신이 onSuccess 후크에서 사실 onSubmit 나에 resetForm를 호출 할 수 있습니다

/// Reset array counts                        
arrayTracker.resetForm(formId);                                                  var vc = AutoForm.getValidationContext(formId);                  
if (vc) {                           
    vc.resetValidation();                        
    // If simpleSchema is undefined, we haven't yet rendered the form, and therefore 
    // there is no need to reset validation for it. No error need be thrown. 
}                             
if (this.doc) {                          
    event.preventDefault();                       
    AutoForm._forceResetFormValues(formId);                   
} 
+0

, 왜 그냥 대신'''onDestroyed''' 방법 내에서 양식을 재설정? – blueren

+0

@blueren 당신의 충고를 시도했습니다 .'Template.myTemplate.onDestroyed (function() { AutoForm.resetForm ("form-id"); }), 변경하지 않았 으면 오류가 계속 발생합니다. 그 뜻 이니? – Ontokrat

+0

양식을 제출 한 후 현재 서식에서 벗어나려고합니까? 내 말은,'''Template.myTemplate.onDestroyed'''가 포스트 폼 제출이라고 부름입니까? – blueren

답변

0

검증 문제가 있다고 생각 해당 폼 코드의 일부이다 . 그냥 폼의 검증 메시지를 재설정하고자하는 경우

AutoForm.addHooks(['form_id'], { 
    onSuccess: function(formType, result) { 
     this.resetForm() 
    } 
}) ; 

Documentation

+0

슬프게도, 오류는 여전히'AutoForm.addHooks ([ 'accountForm'], { onSuccess : function (formType, result) { this.resetForm() } }); ' – Ontokrat

+0

정확한 오류의 스크린 샷을 가져올 수 있습니까? 그리고''''vc''를 어디에서 정의하고 있습니까? 또한, 호기심 때문에 유성에 대한 aldeed 패키지의 npm 버전을 사용하고 있으며 유성 유적 패키지가 아닌 특별한 이유가 있습니까? – blueren

+1

스크린 샷의 정확한 오류 : https://snag.gy/p3mQ8L.jpg 어디서나 vc를 정의하지 않고 있습니다 ... aldeed의 간단한 스키마 nmp 버전을 사용하고 있습니다. 원인을 알 수 있습니다 : collection2는 가치가 떨어지고 udpate는 aldeed : collection2-core에는 nmp 버전이 필요합니다 (https://github.com/aldeed/meteor-collection2#important-note-the-version-in-this-repo-is-deprecated) – Ontokrat