Javascript event handler order

后端 未结 4 1426
我在风中等你
我在风中等你 2020-12-03 14:37

I have an input field, which has two event handlers bound to it.

Validate & AutoSave

Obviously I want to validate before I save. If validation fails, the

4条回答
  •  感情败类
    2020-12-03 15:04

    Normally you'd have the Save event handler call Validate() which will return true if everything is fine and ready to be saved.

    function onSaved() {
      if (!validate()) {
        // set class
        return;
      }
    
      // do the save
    }
    

提交回复
热议问题