Skip to content

Instantly share code, notes, and snippets.

View nauvalidzi's full-sized avatar
🏠
Working from home

Nauval Hafidzi nauvalidzi

🏠
Working from home
  • Surabaya, Indonesia
View GitHub Profile
// edit select option with select2
$('#column').append(`<option value="${res.data.id}" selected>${res.data.text}</option>`);
// addnew radio or checkbox
$('#form').find('input[name=gender]').removeAttr('checked');
// addnew radio or checkbox
$(`input[name=gender][value=${data.gender}]`).prop('checked', true);
// source = https://github.com/select2/select2
$('#select2').select2({
placeholder: 'Select the product',
ajax: {
url: "https://dummyjson.com/products",
processResults: function ({data}) {
return {
results: $.map(data, function (item) {
return {