douyan8070
2016-12-30 05:33
浏览 165
已采纳

上传图像时禁用发布按钮

I found a lot of information about disable double click and disable button waiting for fill out the form.

In this particular case, I have a classified ads website and I need to disable the publish button JUST while the image is uploading, not before, not after just to be clear.

Why? because is the user click on submit and the image is not complete uploaded will not going to be posted into the ads.

I hope any of you guys can help me:

I try with something like this:

$(document).ajaxStart(function () {
    $("#submit").prop("disabled", true);
});

And this is my image upload code:

 <?php if(osc_images_enabled_at_items()) {
          if(modern_is_fineuploader() && osc_get_preference('image_upload', 'zara_theme') == 1) {
            ItemForm::ajax_photos();
            echo '</div>';
        } else { ?>
          <div class="row">
            <input type="file" name="photos[]" multiple />
          </div>
        </div>
        <a id="new-pho" href="#" onclick="addNewPhotoZara(); uniform_input_file(); return false;"><?php _e('Add new photo', 'zara'); ?></a>
      <?php } ?>
    </div>
    <?php } ?>

Input:

<button type="submit" class="btn btn-primary" onclick="return loadSubmit()"><?php _e('Publish item', 'zara'); ?></button>

图片转代码服务由CSDN问答提供 功能建议

我发现很多关于禁用双击和禁用按钮的信息等待填写表格。

在这种特殊情况下,我有一个分类广告网站,我需要在图片上传时禁用发布按钮,而不是在之前,而不是仅仅为了清除之后。 \ ñ

为什么呢? 因为用户点击提交并且图片不完整上传将不会发布到广告中。

我希望你们中的任何人都可以帮助我: \ n

我尝试这样的事情:

  $(document).ajaxStart(function(){
 $(“#submit”)。prop(  “disabled”,true); 
}); 
   
 
 

这是我的图片上传代码:

 &lt;?php if(osc_images_enabled_at_items()){
 if(modern_is_fineuploader()&amp;&amp; osc_get_preference('image_upload','zara_theme')== 1){
 ItemForm :: ajax_photos(); 
 echo  '&lt; / div&gt;'; 
}其他{?&gt; 
&lt; div class =“row”&gt; 
&lt; input type =“file”name =“photos []”multiple /&gt; \  n&lt; / div&gt; 
&lt; / div&gt; 
&lt; a id =“new-pho”href =“#”onclick =“addNewPhotoZara(); uniform_input_file(); return false;”&gt;&lt;?  php _e('添加新照片','zara');  ?&gt;&lt; / a&gt; 
&lt;?php}?&gt; 
&lt; / div&gt; 
&lt;?php}?&gt; 
   
 
 <  p>输入: 
 
 
 &lt; button type =“submit”class =“btn btn-primary”onclick =“return loadSubmit()”&gt;&lt;?php _e(  '发布项','zara');  ?&gt;&lt; / button&gt; 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongpan1871 2016-12-30 05:40
    已采纳

    You can use https://github.com/blueimp/jQuery-File-Upload

    Take a look on example code for disable and enable property 'disabled' on submit button:

    $('#file').simpleUpload("/ajax/upload.php", {
    
    start: function(file){
          $("#submit").prop("disabled", true);
    },
    progress: function(progress){
        //received progress 
    },
    success: function(data){
          $("#submit").prop("disabled", false);
    },
    error: function(error){
        //upload failed 
    }
    });
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dppi5167 2016-12-30 05:38

    You forgot to add id attribute

    Change from

    <button type="submit" class="btn btn-primary" onclick="return loadSubmit()"><?php _e('Publish item', 'zara'); ?></button>
    

    to

    <button type="submit" id="submit" class="btn btn-primary" onclick="return loadSubmit()"><?php _e('Publish item', 'zara'); ?></button>
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题