I have a form that contains a p:fileUpload component as well as an h:graphicImage component. The h:graphicImage component is only rendered once the file has been uploaded via AJAX.
My problem is that I need to execute Jcrop(an image-cropping library) after the file has been uploaded, but the image that I need to execute JCrop on is rendered via ajax and so doesn't exist at when the document is ready
I have something vaguely like this:
<form>
<p:fileUpload fileUploadListener="#{personController.uploadFile}" />
<h:graphicImage id="profilePicture" value="images/#{personController.uploadedFile}" rendered="#{personController.fileUploaded}" />
</form>
<script type="text/javascript">
$(function() {
//Wont get called due to partial page refresh
$('#profilePicture').JCrop()
})
</script>
How can I do this?