I would like to include html data loaded from ajax request and trigger click event on images in my html data. I understand that this is wrong in SPA world but I need displays data from wysiwyg editor...
This is code refactored from version with jQuery:
$http.get('Help/Help/GetHelp', { params: { helpId: contentKey } }) .success(function(data) {
if (data.success) {
// viewData is html from wysiwyg editor
$scope.viewData = data.viewData;
// HERE is problem because now images isn't in DOM. This is too early
angular.element('div#content').find('img').click(function () {
// Show image in gallery
});
} else {
$scope.viewData = "";
}
});
But it does not function because images isn't in DOM when I trigger click event on them... What is the best practice to solve this issue?
Thanks!