Drupal7:通过按其他 ajax 按钮阻止图像上传



我已经通过结构创建了一个表单1. 从物理模块field_dimensions。2.然后添加了图像字段field_image3.通过form_alter添加了AJAX按钮。下面提及

      $form['getquote_fs']['getquote']['get-quote-btn'] = array(
    '#type' => 'button',
    '#name' => 'estimate',
    '#button_type' => 'button',
    '#executes_submit_handler' => false,
    '#limit_validation_errors' => array(array('field_dimensions')),
    '#size' => 5,
    '#weight' => 100,
    '#default_value' => '<span class="bold sd-red">get</span> <span class="normal sd-orange">estimate</span>',
    '#maxlength' => 5,
    '#description' => t('an industry estimate of how much would I pay.'),
    '#ajax' => array(
        'callback' => 'custom_startrack_ajax_cal',
        'method' => 'replace',
        'prevent'=> 'sumbit',
     ),
  );

现在,当我在表单内浏览图像并按其他 ajax 按钮之一时。它直接上传图像。我如何将其从文件夹中上传中删除

您可以使用jquery轻松禁用按钮的行为。

尝试以下方法之一:

$("#your-button-id").submit(function(e){
   return false;
});

$("#your-button-id").submit(function(e){
    e.preventDefault();
 });

最新更新