How to disable Ajax-upload button?

◇◆丶佛笑我妖孽 提交于 2019-12-13 02:17:56

问题


I'm trying to use this plugin http://valums.com/ajax-upload/. I added a file-limit, I want to disable the upload button (not hide, just disable). E.g.

if(filesNumber>=limit)
{
    //Disable the "Upload a file" button    
}

So, if the user will try to upload another file, he should see a message that the limit is exceeded. Can you look at this plugin and help me?

The button is not a form button, it is a div with css.

var btnUpload=$('#<?=$filesManagerCode?>upload');
        new AjaxUpload(btnUpload, {
            action: '<?=$boxLink?>actionMode<?=LDTR?>addfile',
            name: 'uploadFile[FilePath]',
            onSubmit: function(file, ext){
                btnUpload.attr('oldContent', btnUpload.html());
                btnUpload.html('<img src="'+jsloader.src+'"/>');
            },
            onComplete: function(file, response, temp){
                btnUpload.html(btnUpload.attr('oldContent'));
                $("#<?=$filesManagerCode?>files").load('<?=$boxLink?>', setFilesLimit(<?=$params['filesLimit']?>));
            }
        });


<div id="<?=$filesManagerCode?>upload" class="uploadButton"><span>Upload file</span> <span id="<?=$filesManagerCode?>uploadLimit"></span></div>

Thanks.


回答1:


    var btnUpload=$('#<?=$filesManagerCode?>upload');
           if(filesNumber>=limit)
{
    //Disable the "Upload a file" button or Do nothing:
       alert("You have reached the upload limit.");
}
else
{
            new AjaxUpload(btnUpload, {
                action: '<?=$boxLink?>actionMode<?=LDTR?>addfile',
                name: 'uploadFile[FilePath]',
                onSubmit: function(file, ext){
                    btnUpload.attr('oldContent', btnUpload.html());
                    btnUpload.html('<img src="'+jsloader.src+'"/>');
                },
                onComplete: function(file, response, temp){
                    btnUpload.html(btnUpload.attr('oldContent'));
                    $("#<?=$filesManagerCode?>files").load('<?=$boxLink?>', setFilesLimit(<?=$params['filesLimit']?>));

            });
}


来源:https://stackoverflow.com/questions/5122602/how-to-disable-ajax-upload-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!