2011-04-22 6 views
0

Mootools의 formRegister에 콜백을 어떻게 등록합니까?자바 스크립트 Mootools 콜백

http://mootools.net/docs/more/Forms/Form.Validator

// 검증.
새 Form.Validator.Inline (myForm, { formValidate : myCallback});

기능 myCallback() {경고 ("양식 유효")}

+0

표시 할 코드 예제가 있습니까? onsuccess 또는 onfailure 같은 – kjy112

+0

? 성공에 – kjy112

+0

나는 그것이 어떻게 작동했는지 나는 약간의 예를 덧붙였다. – Prospero

답변

1

이 그것을하는 방법 중 하나입니다. Mootools 데모에서 onSuccess 콜백을 첨부하여 다음 작업을 수행 할 수 있습니다. :

window.addEvent('domready', function(){ 

    // The elements used. 
    var myForm = document.id('myForm'), 
     myResult = document.id('myResult'); 

    // Labels over the inputs. 
    myForm.getElements('[type=text], textarea').each(function(el){ 
     new OverText(el); 
    }); 

    // Validation. 
    new Form.Validator.Inline(myForm); 

    // Ajax (integrates with the validator). 
    new Form.Request(myForm, myResult, { 
     requestOptions: { 
      'spinnerTarget': myForm 
     }, 
     extraData: { // This is just to make this example work. 
      'html': 'Form sent.' 
     }, 
     onSuccess: function(result){ //callback function added to demo 
      console.log(result); 
     } 
    }); 
} 
+0

나는 단어를 사용하지 않았다. 때로는 (항상) 나는 JS가 너무 굉장하다고해도 싫어합니다. – Prospero

관련 문제