When I rendered the HTML data, the following code was loading the HTML data with the success function:
$(document).on("change", ".product", function() {
var selectval = $(this);
$.ajax({
url: '/purchase-order/ajax/load-attrs/',
type: "POST",
dataType: 'json',
data: {
'product': $(this).parents('tr').find(".product").val()
},
success: function (data) {
selectval.parents('tr').find(".product_attr").html(data);
console.log(data)
}
});
});
All I need is:
How do I populate data in a specific class in the Select 2 process result? How do I use this selectval.parents('tr').find(".product_attr")
inside processResults
?
$(document).on("change", ".product", function() {
var selectval = $(this);
$.ajax({
url: '/purchase-order/ajax/load-attrs/',
type: "POST",
dataType: 'json',
data: {
'product': $(this).parents('tr').find(".product").val()
},
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {id: item.id, text: item.sku};
})
};
},
success: function (data) {
selectval.parents('tr').find(".product_attr").html(data);
console.log(data)
}
});
});
Any help would be greatly appreciated
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…