Skip to content

Commit 43d5cac

Browse files
Merge pull request #57 from mlakatkou/GS-3273
[update] attachevent article
2 parents 51794af + 4b573f6 commit 43d5cac

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

docs/api/method/attachevent.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ description: "attaches the handler to an inner event of dhtmlxGantt"
2424
### Example
2525

2626
~~~jsx
27-
gantt.attachEvent("onTaskClick", function(id, e) {
28-
alert("You've just clicked an item with id="+id);
27+
gantt.attachEvent("onTaskClick", (id, e) => {
28+
alert(`You've just clicked an item with id=${id}`);
2929
});
3030
~~~
3131

@@ -35,47 +35,46 @@ gantt.attachEvent("onTaskClick", function(id, e) {
3535
### Details
3636

3737
You can attach several handlers to the same event and all of them will be executed.
38-
If some of handlers will return *false* - the related operation will be blocked.
38+
If some of the handlers return *false*, the related operation will be blocked.
3939
Event handlers are processed in the same order that they were attached.
4040

41-
42-
## Properties of settings object
41+
## Properties of settings object
4342

4443
The settings object can contain the following properties:
4544

46-
- **id?** - (*string | number*) - the id of the event handler.
45+
- `id?` - (*string | number*) - the id of the event handler.
4746
For example, you can easily detach a handler from the specified event:
4847

49-
~~~js
50-
gantt.attachEvent("onTaskClick", function(){
48+
~~~js {3}
49+
gantt.attachEvent("onTaskClick", () => {
5150
console.log("task click");
52-
}, {id: "my-click"}); /*!*/
53-
... //after a while:
51+
}, { id: "my-click" });
52+
53+
// after a while
5454
gantt.detachEvent("my-click");
5555
~~~
5656

57-
- **once?** - (*boolean*) - defines whether the event will be executed only once.
57+
- `once?` - (*boolean*) - defines whether the event will be executed only once.
5858
Set the property to *true* if you want to capture the first triggering of the event, as in:
5959

60-
~~~js
61-
gantt.attachEvent("onTaskClick", function(){
60+
~~~js {4}
61+
gantt.attachEvent("onTaskClick", () => {
6262
console.log("capture next task click");
6363
return true;
64-
}, {once: true}); /*!*/
64+
}, { once: true });
6565
~~~
6666

67-
- **thisObject?** - (*any*) - specifies the `this` object for the listener.
67+
- `thisObject?` - (*any*) - specifies the `this` object for the listener.
6868

69-
~~~js
70-
gantt.attachEvent("onTaskClick", function(){
69+
~~~js {4}
70+
gantt.attachEvent("onTaskClick", function() {
7171
// ...
7272
return true;
73-
}, {thisObject: this}); /*!*/
73+
}, { thisObject: this });
7474
~~~
7575

7676
### Related API
7777
- [detachEvent](api/method/detachevent.md)
7878

7979
### Related Guides
8080
- [Event Handling](guides/handling-events.md)
81-

0 commit comments

Comments
 (0)