Service Portal widget event handler

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2018 12:26 PM
I want to add an event handler for when the form has been loaded so I added following in the Client script in a new widget.
$rootScope.$on('spModel.gForm.initialized', function (e, gFormInstance) {
console.log('In spModel.gForm.initialized');
});
I have also tried
$scope.$on('spModel.gForm.initialized', function (e, gFormInstance) {
console.log('In spModel.gForm.initialized');
});
But nothing happens what the pages is loaded.
The weird thing is that I have another widget (more complex one with both client and server scripts) where I use the exact same code and in that widget it works fine.
Of course both $scope and $rootScope is injected with
function($scope, $rootScope)
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2021 07:33 AM
Hello there,
See if this works for you:
$rootScope.$on('spModel.gForm.rendered', function (e, gFormInstance)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 03:00 PM
You should be listening for 'spModel.gForm.rendered' on $rootScope, not $scope.
$rootScope.$on('spModel.gForm.rendered', function (event, g_form) {
console.log('spModel.gForm.rendered fired');
// you can safely use g_form as you would in a client script
});