Use of this code (var c = this;) in widget controller
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2019 02:24 AM
In service portal widgets, i am seeing some widgets are using "var c = this;" and some widgets are not using in controller part of widget.Please let me know use of this code (var c = this;) particular.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2019 02:44 AM
Hi goru,
var c=this;
That is used to bind client script and server script within a widget.
example:-
c.server.update - here controller is used to update the server script from client script.
mark it as correct/helpful if you find it helpful.
Regards,
Ragini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2019 03:33 AM
Hi Goru
There is a lot of significance for "this" keyword. It may vary depends on situation where it is used. It refers to the client script object.
you can assign "this" to any javascript variable.
Here is the link which might give you more info: https://toddmotto.com/understanding-the-this-keyword-in-javascript/
Please Mark Helpful/Correct, if it is helpful to you.
Regards
Sai