Last active
May 25, 2016 18:45
-
-
Save travist/1b4b3f177b9658719dec35dc05a47799 to your computer and use it in GitHub Desktop.
Trigger event on Form Rendering completed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.controller('renderComplete', [ | |
'$scope', | |
'FormioUtils', | |
function( | |
$scope, | |
FormioUtils | |
) { | |
var renderComplete = function() { | |
$scope.$emit('formRenderComplete'); | |
}; | |
var numRendered = 0; | |
var numComponents = 0; | |
$scope.$on('formElementRender', function(event, element) { | |
numRendered++; | |
if (numComponents && (numComponents === numRendered)) { | |
renderComplete(); | |
} | |
}); | |
$scope.$on('formLoad', function(event, form) { | |
FormioUtils.eachComponent(form.components, function() { | |
numComponents++; | |
}, true); | |
if (numComponents && (numComponents === numRendered)) { | |
renderComplete(); | |
} | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment