Arshad Ali

Arshad Ali

  • NA
  • 636
  • 33.6k

Selec2 Value not binding when i update the record?

Oct 4 2020 10:32 AM
Hi Friends,
 
I am using the select2 controller binding the data on page load is working fine but when I click on the particular record the data not bind the properly on select2 controller.code is below.please guide thanks
  1. function openMembershipPlanOfferModal(id) {    
  2.     
  3.     var url = '/MembershipPlanOffer/Upsert/';    
  4.     if (id != undefined) {    
  5.         url = url + id;    
  6.     }    
  7.     $('#membershipPlanId').select2({    
  8.         ajax: {    
  9.             contentType: 'application/json; charset=utf-8',    
  10.             dataType: 'json',    
  11.             type: 'GET',    
  12.             url: url,    
  13.             success: function (response) {    
  14.                     
  15.                 console.log(response);    
  16.                 var membershipPlans = [];    
  17.                 response.data.forEach(function (value, key) {    
  18.                     membershipPlans.push({ id: value.id, text: value.name })    
  19.                 });    
  20.             }    
  21.         }    
  22.     });    
  23.     $.get(url, function (data) {    
  24.         $("#membershipPlanOfferModal").html(data);    
  25.         $("#membershipPlanOfferModal").modal('show');    
  26.     });    
  27.       
  28. };  

Answers (1)