You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's cover various events that accompany data updates.
3
+
Mari kita bahas berbagai *event* yang menyertai pembaruan data.
4
4
5
5
## Event: change
6
6
7
-
The`change`event triggers when the element has finished changing.
7
+
*Event*`change`terpicu saat elemen selesai diubah.
8
8
9
-
For text inputs that means that the event occurs when it loses focus.
9
+
Untuk input teks, itu berarti bahwa *event* terjadi ketika kehilangan fokus.
10
10
11
-
For instance, while we are typing in the text field below -- there's no event. But when we move the focus somewhere else, for instance, click on a button -- there will be a `change` event:
11
+
Misalnya, saat kita mengetik di *field* teks di bawah -- tidak ada *event*. Tetapi ketika kita memindahkan fokus ke tempat lain, misalnya, klik tombol -- akan ada *event*`change`:
12
12
13
13
```html autorun height=40 run
14
14
<inputtype="text"onchange="alert(this.value)">
15
15
<inputtype="button"value="Button">
16
16
```
17
17
18
-
For other elements: `select`, `input type=checkbox/radio`it triggers right after the selection changes:
18
+
Untuk elemen lain: `select`, `input type=checkbox/radio`yang dipicu tepat setelah pilihan berubah:
19
19
20
20
```html autorun height=40 run
21
21
<selectonchange="alert(this.value)">
@@ -29,11 +29,11 @@ For other elements: `select`, `input type=checkbox/radio` it triggers right afte
29
29
30
30
## Event: input
31
31
32
-
The`input`event triggers every time after a value is modified by the user.
32
+
*Event*`input`terpicu setiap kali nilai telah diubah oleh pengguna.
33
33
34
-
Unlike keyboard events, it triggers on any value change, even those that does not involve keyboard actions: pasting with a mouse or using speech recognition to dictate the text.
34
+
Tidak seperti *event* keyboard, *event*`input` memicu perubahan *value* apa pun, bahkan yang tidak melibatkan tindakan keyboard: menempelkan dengan mouse atau menggunakan pengenalan suara untuk mendikte teks.
If we want to handle every modification of an `<input>`then this event is the best choice.
47
+
Jika kita ingin menangani setiap modifikasi `<input>`maka *event* ini adalah pilihan terbaik.
48
48
49
-
On the other hand, `input`event doesn't trigger on keyboard input and other actions that do not involve value change, e.g. pressing arrow keys`key:⇦``key:⇨`while in the input.
49
+
Di sisi lain, *event*`input`tidak dipicu pada input keyboard dan tindakan lain yang tidak melibatkan perubahan nilai, misalnya menekan tombol panah`key:⇦``key:⇨`saat memasukkan.
The`input`event occurs after the value is modified.
51
+
```smart header="Tidak dapat mencegah apa pun di`oninput`"
52
+
*Event*`input`terjadi setelah nilai diubah.
53
53
54
-
So we can't use `event.preventDefault()`there -- it's just too late, there would be no effect.
54
+
Jadi kita tidak bisa menggunakan `event.preventDefault()`disana -- terlalu terlambat, tidak akan ada efeknya.
55
55
```
56
56
57
57
## Events: cut, copy, paste
58
58
59
-
These events occur on cutting/copying/pasting a value.
59
+
*Event* ini terjadi saat memotong/menyalin/menempelkan nilai.
60
60
61
-
They belong to [ClipboardEvent](https://www.w3.org/TR/clipboard-apis/#clipboard-event-interfaces) class and provide access to the data that is copied/pasted.
61
+
Mereka termasuk dalam kelas [ClipboardEvent](https://www.w3.org/TR/clipboard-apis/#clipboard-event-interfaces) dan menyediakan akses ke data yang disalin/ditempel.
62
62
63
-
We also can use `event.preventDefault()` to abort the action, then nothing gets copied/pasted.
63
+
Kita juga bisa menggunakan `event.preventDefault()` untuk membatalkan aksi, maka tidak akan ada yang disalin/ditempel.
64
64
65
-
For instance, the code below prevents all such events and shows what we are trying to cut/copy/paste:
65
+
Contohnya, kode di bawah ini mencegah semua *event* tersebut dan menunjukkan apa yang kita coba potong/salin/tempel:
66
66
67
67
```html autorun height=40 run
68
68
<input type="text" id="input">
@@ -74,22 +74,22 @@ For instance, the code below prevents all such events and shows what we are tryi
74
74
</script>
75
75
```
76
76
77
-
Please note, that it's possible to copy/paste not just text, but everything. For instance, we can copy a file in the OS file manager, and paste it.
77
+
Harap dicatat, bahwa memungkinkan untuk salin/tempel tidak hanya teks, tetapi semuanya. Misalnya, kita dapat menyalin file di manajer file OS, dan menempelkannya.
78
78
79
-
That's because`clipboardData`implements `DataTransfer` interface, commonly used for drag'n'drop and copy/pasting. It's bit beyound our scope now, but you can find its methods [in the specification](https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface).
79
+
Itu karena`clipboardData`mengimplementasikan *interface*`DataTransfer`, yang biasa digunakan untuk drag'n'drop dan salin/tempel. Ini sedikit di luar jangkauan kita sekarang, tetapi Anda dapat menemukan metodenya [dalam spesifikasi ini](https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface).
80
80
81
-
```warn header="ClipboardAPI: user safety restrictions"
82
-
The clipboard is a "global" OS-level thing. So most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety, e.g. in `onclick` event handlers.
*Clipboard* adalah hal "global" tingkat OS. Jadi sebagian besar peramban mengizinkan akses baca/tulis ke *clipboard* hanya dalam lingkup tindakan pengguna tertentu untuk keamanan, misalnya di *event handler* `onclick`.
83
83
84
-
Also it's forbidden to generate "custom" clipboard events with `dispatchEvent` in all browsers except Firefox.
84
+
Juga dilarang untuk membuat *event* *clipboard* "custom" dengan `dispatchEvent` di semua peramban kecuali Firefox.
85
85
```
86
86
87
-
## Summary
87
+
## Ringkasan
88
88
89
-
Data change events:
89
+
*Event* perubahan data:
90
90
91
-
| Event |Description| Specials |
91
+
|*Event*|Deskripsi| Specials |
92
92
|---------|----------|-------------|
93
-
|`change`|A value was changed. |For text inputs triggers on focus loss. |
94
-
|`input`|For text inputs on every change. |Triggers immediately unlike`change`. |
95
-
|`cut/copy/paste`|Cut/copy/paste actions. |The action can be prevented. The`event.clipboardData`property gives read/write access to the clipboard. |
93
+
|`change`|Sebuah *value* diubah. |Untuk pemicu input teks pada saat kehilangan fokus. |
94
+
|`input`|Untuk input teks pada setiap perubahan. |Pemicu langsung tidak seperti`change`. |
95
+
|`cut/copy/paste`|Tindakan potong/salin/tempel. |Tindakan tersebut dapat dicegah. Properti`event.clipboardData`memberikan akses baca/tulis ke *clipboard*. |
0 commit comments