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
Copy file name to clipboardExpand all lines: 2-ui/2-events/05-dispatch-events/article.md
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,19 +158,19 @@ alert(event.clientX); // undefined, the unknown property is ignored!
158
158
159
159
## event.preventDefault()
160
160
161
-
Many browser events have a "default action", such as navigating to a link, starting a selection, and so on.
161
+
بسیاری از رویدادهای مرورگر دارای یک "default action" هستند، مانند پیمایش یک لینک، شروع یک انتخاب و غیره.
162
162
163
-
For new, custom events, there are definitely no default browser actions, but a code that dispatches such event may have its own plans what to do after triggering the event.
163
+
برای event های جدید و custom events، قطعاً هیچ اقدام پیشفرض مرورگر وجود ندارد، اما کدی که چنین رویدادی را ارسال میکند ممکن است برنامههای خاص خود را داشته باشد که پس از راهاندازی رویداد چه کاری انجام دهد.
164
164
165
-
By calling`event.preventDefault()`, an event handler may send a signal that those actions should be canceled.
165
+
با فراخوانی`event.preventDefault()`، یک کنترل کننده رویداد ممکن است سیگنالی ارسال کند که آن اقدامات باید لغو شوند.
166
166
167
-
In that case the call to `elem.dispatchEvent(event)`returns `false`. And the code that dispatched it knows that it shouldn't continue.
167
+
در آن صورت فراخوانی به `elem.dispatchEvent(event)` false برمی گردد. و کدی که آن را ارسال کرده می داند که نباید ادامه یابد.
168
168
169
-
Let's see a practical example - a hiding rabbit (could be a closing menu or something else).
169
+
بیایید یک مثال عملی ببینیم - یک خرگوش پنهان (ممکن است منوی بسته شدن یا چیز دیگری باشد).
170
170
171
-
Below you can see a `#rabbit` and `hide()` function that dispatches `"hide"` event on it, to let all interested parties know that the rabbit is going to hide.
171
+
در زیر میتوانید یک تابع #rabbit and hide() را مشاهده کنید که رویداد "hide" را روی آن ارسال میکند تا به همه علاقهمندان اطلاع دهد که خرگوش قرار است مخفی شود.
172
172
173
-
Any handler can listen for that event with `rabbit.addEventListener('hide',...)`and, if needed, cancel the action using `event.preventDefault()`. Then the rabbit won't disappear:
173
+
هر کنترلکنندهای میتواند با `rabbit.addEventListener('hide',...)`به آن رویداد گوش دهد و در صورت نیاز، عمل را با استفاده از `event.preventDefault()` لغو کند. سپس خرگوش ناپدید نمی شود:
174
174
175
175
```html run refresh autorun
176
176
<preid="rabbit">
@@ -201,8 +201,7 @@ Any handler can listen for that event with `rabbit.addEventListener('hide',...)`
201
201
});
202
202
</script>
203
203
```
204
-
205
-
Please note: the event must have the flag `cancelable: true`, otherwise the call `event.preventDefault()` is ignored.
204
+
نکته: event حتما باید flag `cancelable: true` را داشته باشد یا اینکه `event.preventDefault()` فراخوانی نمیشود.
0 commit comments