Monday, June 27, 2016

How to disable Choose button in PrimeFaces fileupload component


The javascript function is to disable "Choose" button in <p:fileUpload /> component a file has been uploaded.
It is applicable to PrimeFaces 3.5

function below will find the Choose button from the passed in widgetVar when the file component onchange,
if the number of uploaded files more than 1,
disable the Choose button.


<script type="text/javascript">

    function onchangeDisableChooseBtn(upload_widget_var) {
        if(upload_widget_var.buttonBar.find('input[type=file]').get(0).type == 'file') {
            upload_widget_var.buttonBar.find('input[type=file]').change(function() {
                var files = upload_widget_var.uploadContent.find('.files tr');
                if (files.length >= 1) {
                    upload_widget_var.buttonBar.find('input[type=file]').get(0).disabled=true;
                }
                onchangeDisableChooseBtn(upload_widget);
            });
        }
    }

</script>



Done!!

1 comment:

  1. Tua Tagovailoa tore them apart like a wolf half in} 먹튀검증사이트 with a poorly made chew toy. One of the biggest causes the Lions lost this high-scoring recreation was their incapability to get off the sphere on third downs. The Edge Full Kit allows you to mount your cellphone to your pocket book, laptop, or pill, and could probably assist you to multitask higher between your hardware and your iPhone. Users of the Mint app can add Apple Card as an official account to track transactions. Apple CEO Tim Cook made an unexpected look at the united states

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...