- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2016 09:56 PM
Does anyone know how to communicate between the 'Link' field if an event is fired within the 'Client controller' field?
For example, if an onClick event is triggered, go to the server get some data and upon return, 'flash/blink' the element in the HTML that is being updated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2016 12:54 AM
Thanks Lars. Finally got it working and communicating through the callback from the server to the "List function" event
Controller
function($scope, $timeout) {
this.view = function(){
$scope.server.get().then(function(response){
angular.element('.js-view').triggerHandler('changed.view', response.data);
// delay the update of the view
$timeout(function(){
angular.extend($scope.data, response.data);
}, 288);
});
}
}
Link
function($scope, element){
$(".js-view", element).on("changed.view", function(evnt, data){
var timer = 288;
//
$(this).fadeOut(timer).fadeIn(timer);
});
}
Update: I added the timeout function directly in the directive because it seems that ServiceNow isn't passing variables (like $timeout) defined in the originating directive "client script" for the Link function. This has to do with populating the view and redrawing it as setTimeout doesn't work. This is when one must fade out the 'view', add new content, and then fadein the new content.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2016 10:56 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2016 12:54 AM
Thanks Lars. Finally got it working and communicating through the callback from the server to the "List function" event
Controller
function($scope, $timeout) {
this.view = function(){
$scope.server.get().then(function(response){
angular.element('.js-view').triggerHandler('changed.view', response.data);
// delay the update of the view
$timeout(function(){
angular.extend($scope.data, response.data);
}, 288);
});
}
}
Link
function($scope, element){
$(".js-view", element).on("changed.view", function(evnt, data){
var timer = 288;
//
$(this).fadeOut(timer).fadeIn(timer);
});
}
Update: I added the timeout function directly in the directive because it seems that ServiceNow isn't passing variables (like $timeout) defined in the originating directive "client script" for the Link function. This has to do with populating the view and redrawing it as setTimeout doesn't work. This is when one must fade out the 'view', add new content, and then fadein the new content.