notice.js
25 lines
| 1 | export default class Notice { |
| 2 | |
| 3 | constructor($element){ |
| 4 | this.$element = $element; |
| 5 | this.key = $element.data('key'); |
| 6 | this.nonce = $element.data('nonce'); |
| 7 | |
| 8 | this.$element.on( 'click', '.notice-dismiss', () => this.onDismissClick() ); |
| 9 | } |
| 10 | |
| 11 | onDismissClick() { |
| 12 | |
| 13 | this.$element.remove(); |
| 14 | |
| 15 | jQuery.ajax({ |
| 16 | type: "POST", |
| 17 | data : { action: "wpmtst_dismiss_notice", nonce: this.nonce, key: this.key }, |
| 18 | url : ajaxurl |
| 19 | }); |
| 20 | } |
| 21 | |
| 22 | } |
| 23 | |
| 24 | |
| 25 |