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
+12-15Lines changed: 12 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Dispatching custom events
2
2
3
-
ما نه تنها می توانیم کنترل کننده ها را اختصاص دهیم، بلکه می توانیم رویدادها را از جاوا اسکریپت نیز تولید کنیم.
3
+
ما نه تنها می توانیم handler ها را اختصاص دهیم، بلکه می توانیم رویدادها را از جاوا اسکریپت نیز تولید کنیم.
4
4
5
5
از رویدادهای سفارشی می توان برای ایجاد "مولفه های گرافیکی" استفاده کرد. به عنوان مثال، یک عنصر ریشه از منوی مبتنی بر JS خودمان ممکن است رویدادهایی را ایجاد کند که میگوید چه اتفاقی در منو میافتد: باز کردن (باز کردن منو)، انتخاب (یک مورد انتخاب شده است) و غیره. کد دیگری ممکن است به رویدادها گوش دهد و آنچه را که در منو اتفاق می افتد مشاهده کند.
6
6
@@ -15,23 +15,22 @@
15
15
letevent=newEvent(type[, options]);
16
16
```
17
17
18
+
پارامتر ها:
18
19
Arguments:
19
20
20
-
-*type* -- event type, a string like `"click"` or our own like `"my-event"`.
21
-
-*options* -- the object with two optional properties:
22
-
-`bubbles: true/false` -- if `true`, then the event bubbles.
23
-
-`cancelable: true/false` -- if `true`, then the "default action" may be prevented. Later we'll see what it means for custom events.
24
-
25
-
By default both are false: `{bubbles: false, cancelable: false}`.
21
+
-*نوع*: event type, یک رشته مانند `"click"` .
22
+
-*گزینه ها*: شی ای با دو ویژگی اختیاری.
23
+
-*Bubbles*:اگر true بود یعنی bubbled می شود.
24
+
-*لغو شدن (true/false)*: اگر ویزگی مقدار true را داشت عمل پیش فرض آن لغو میشود،
25
+
- به صورت پیش فرض: `{bubbles: false, cancelable: false}`.
26
26
27
27
## dispatchEvent
28
28
29
-
After an event object is created, we should "run" it on an element using the call `elem.dispatchEvent(event)`.
30
-
31
-
Then handlers react on it as if it were a regular browser event. If the event was created with the `bubbles` flag, then it bubbles.
29
+
پس از ایجاد یک event، باید آن را روی یک element با استفاده از فراخوانی elem.dispatchEvent(event) اجرا کنیم.
32
30
33
-
In the example below the `click` event is initiated in JavaScript. The handler works same way as if the button was clicked:
31
+
سپس handler ها به آن واکنش نشان می دهند که گویی یک رویداد معمولی مرورگر است. اگر رویداد با bubble flag ها ایجاد شده باشد، bubbled می شود.
34
32
33
+
در مثال زیر رویداد کلیک در جاوا اسکریپت آغاز می شود. handler به همان روشی کار می کند که اگر روی دکمه کلیک شده باشد:
0 commit comments