第一个select2正在工作,但第二个select2不工作...没有打开第二个

时间:2017-10-28 09:42:56

标签: javascript php jquery

我的第二个克隆Select2不能正常工作第一个正常工作... 这是我的代码...... 从很长一段时间做,但我被困在select2函数



  var cont= 1
  $('#addButton').click(function(){
  var newId           = "Quotation_"+cont
  var locationId      = "new_"+cont
  var apt_nameId      = "apt_name"//+cont
  var choose_roomId   = "choose_room"//+cont
  var act_tariffId    = "act_tariff"//+cont
  var dcnt_tariffId   = "dcnt_tariff"//+cont
  var urlId           = "url"//+cont

  //$('h5').append("<hr>");
  $('h5').append($('.row-container:first').clone());
  $('.row-container:last').find("#Quotation_").attr("id",newId);
   $('.row-container:last').find("#new_").attr("id",locationId);
   
$(".property_add_").select2({
  "val": null,
  theme: "bootstrap",
    width: '100%', 
  
  placeholder: "Select Address"
}).select2("val", null);

 $('#new_').on(function() {

  //alert();

  //$('#property_address').val($(this).find(':selected').data('propertyaddress'));

  $('#apt_name').val($(this).find(':selected').data('apartments_type'));

});


//-------------------------------

  $('#new_').change(function( ) {
  $('#apt_name').val($(this).find(':selected').data('apartments_type'));

});
cont++

function property_address1()
   {
     $query = $this->db->query('SELECT host, apartments_type, propertyaddress FROM tbl_contacts')->result();
     $output = '<select id="new_" class="property_add_ form-control">';
    
    foreach ($query as $row) 
    {
        //echo $row->location;
        $output .= "<option value='". $row->propertyaddress ."'";
       
        $output .= " data-host_name='" . $row->host ."'" ;

        $output .= " data-apartments_type ='" . $row->apartments_type."'" ;

        $output .=   $row->host . ' , '.$row->propertyaddress . ' ,'.$row->price. ' ,'.$row->apartments_type. ' , '. $row->contactperson . ' , ' . $row->contactnumber. "</option>";
    }
    $output .= '</select>';
    //var_dump($output);
    return $output;
   
    }
&#13;
&#13;
&#13;

这样做很长一段时间,但每次我悲惨地失败..我尝试用类,名称,id做代码所有的方法都是faill但最后我要求stackover流程也许你帮助我从灾难中

0 个答案:

没有答案