select2 fix
This commit is contained in:
parent
9731fa83f3
commit
4e5882411b
|
@ -72,10 +72,6 @@ $("#universal_table_tags").select2({
|
||||||
$("#universal_table_tags").val(<%= raw(@entry.table_tags. collect { |tag| tag.id.to_s }) %>).trigger("change");
|
$("#universal_table_tags").val(<%= raw(@entry.table_tags. collect { |tag| tag.id.to_s }) %>).trigger("change");
|
||||||
|
|
||||||
const preselectedData = $("#table_entry_related_entries").data('value');
|
const preselectedData = $("#table_entry_related_entries").data('value');
|
||||||
preselectedData.forEach(function(item) {
|
|
||||||
var option = new Option(item.text, item.id, true, true);
|
|
||||||
$('#table_entry_related_entries').append(option);
|
|
||||||
});
|
|
||||||
var select2Options = {
|
var select2Options = {
|
||||||
maximumSelectionSize: 10,
|
maximumSelectionSize: 10,
|
||||||
minimumResultsForSearch: Infinity,
|
minimumResultsForSearch: Infinity,
|
||||||
|
@ -100,16 +96,16 @@ $("#universal_table_tags").select2({
|
||||||
cache: false
|
cache: false
|
||||||
},
|
},
|
||||||
formatResult: function(i) {
|
formatResult: function(i) {
|
||||||
console.log(i)
|
|
||||||
return '<div>' + i.text + '</div>';
|
return '<div>' + i.text + '</div>';
|
||||||
}, // Formats results in drop down
|
},
|
||||||
formatSelection: function(i) {
|
formatSelection: function(i) {
|
||||||
return '<div>' + i.text + '</div>';
|
return '<div>' + i.text + '</div>';
|
||||||
}, //Formats result that is selected
|
},
|
||||||
escapeMarkup: function(m) {
|
escapeMarkup: function(m) {
|
||||||
return m;
|
return m;
|
||||||
} // we do not want to escape markup since we are displaying html in results
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#table_entry_related_entries").select2(select2Options).trigger("change");
|
$("#table_entry_related_entries").select2(select2Options);
|
||||||
|
$("#table_entry_related_entries").select2('data', preselectedData);
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue