2016-10-11 80 views
0

我有一个动态显示的xeditable字段。我想用select2来更新它。可编辑的Select2不起作用

$(document).ajaxComplete(function() { 

     $('.marketing_event_id').editable({ 
      emptytext: ".....", 
      url: "ajax_xeditable_update.php?table=appointments", 
      source: promo_codes, 
      select2: { 
       width: 200, 
       placeholder: 'Select promotion code...', 
       allowClear: true, 
      } 
     }); 


    }); 

//get the promo codes for the select2 box for xeditable. put it outside of ajaxcomplete so it doesn't keep firing off for every appt! 

    var promo_codes = []; 

    $.getJSON('ajax_get_json.php?what=location_promo_codes', function (data) { 

     $.each(data, function (index) { 
      promo_codes.push({ 
       id: data[index].value, 
       text: data[index].text 
      }); 
     }); 

    }); 

的选择2中显示了所有JSON正确的选项给用户,但是当选择一个选项,并在“对号”按钮选择要更新的领域,没有任何反应。我正在观看Chrome中的网络屏幕,Xeditable字段的网址甚至没有激活。

这里是我的html场的样子:

echo '<h5>Promotion Code: <a href="#" class="marketing_event_id appointment' . $result->id . '" data-name="marketing_event_id" data-type="select2" data-value="'; if(!empty($result->marketing_event_id)) { echo $result->marketing_event_id; } echo '" data-placement="right" data-original-title="Enter the appointment promo code." data-pk="'. $result->id . '">' . $result->promo_code .'</a></h5> 

的数据字段被填充的罚款。我没有看到任何错误。

这里是一个被用来填充选择2中的getJSON信息的样本:

[{"value":"663","text":"christmas2015"},{"value":"651","text":"web08"},{"value":"658","text":"paper0815"}] 

我会很高兴,如果需要提供更多的代码。

任何人都可以解释为什么该字段更新时不会触发该URL?谢谢。

回答

0

我想通了,但我不明白为什么这个工程。

我添加一行代码到xeditable面积:

$('.marketing_event_id').editable({ 
      emptytext: ".....", 
      container: 'body', <---- THIS IS WHAT I ADDED TO MAKE IT WORK!!!! 
      url: "ajax_xeditable_update.php?table=appointments", 
      source: promo_codes, 
      select2: { 
       width: 200, 
       placeholder: 'Select promotion code...', 
       allowClear: true, 
      } 
     });