1. Home
  2. 멤버스(회원가입) 시즌2
  3. 엠샵 멤버스폼 포스트 액션
  4. 이벤트 트리거

이벤트 트리거

1. 이벤트 트리거

엠샵멤버스-멤버스액션-포스트액션-코드엠샵_메뉴얼-1

포스트 액션을 이벤트 트리거로 설정하면, 폼이 제출될 때 자바스크립트 이벤트의 트리거가 실행됩니다.

예를 들어 이벤트 트리거를 my_js_event 로 저장했을 경우, 차일드테마 안에 있는 functions.php샘플코드를 추가해주시면, 폼이 제출된 후 $(body).trigger(‘my_js_event’, formController);가 호출됩니다.


2. 샘플 코드

add_action( 'wp_head', 'output_my_event_handler' );

function output_my_event_handler() {
  ?>
  <script>
    jQuery( document ).ready( function ( $ ) {
      $( 'body' ).on( 'my_js_event', function () {
        alert( 'test' );
      } );
    } );
  </script>
  <?php
}
  • alert( ‘test’ ); 부분에 원하시는 작업을 진행하여 주시면 됩니다.

 

Was this article helpful to you? Yes No