2017-01-24 88 views
1

我已经创建了一个表格,通过结构 1. field_dimensions from physcial模块。 2.然后添加图像字段field_image 3.通过form_alter添加ajax按钮。下面提Drupal7:通过按下其他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 button.Its直接上传image.How我可以被上传的文件夹中删除它

回答

0

可以禁用jquery轻松实现按钮的行为。

尝试其中之一:

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

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

我已经试过这..its不工作 –