Estoy tratando de cargar datos adicionales en mi selección (select2), pero el Evento desencadenante no está cargando los datos adicionales. El código y los resultados se muestran a continuación.
$('#section').select2(); var data = { id: 1, text: 'text_default', anothertext: 'text_2' }; var newOption = new Option(data.text, data.id, true, true); $('#section').append(newOption).trigger('change'); //until this point, everything works $('#section').trigger({ type: 'select2:select', params: { data: data } }); console.log($('#section').select2('data')[0]['text']);// return text_default console.log($('#section').select2('data')[0]['anothertext']);// return undefined console.log($('#section').select2('data')['anothertext']);//only for test, return undefined console.log($('#section').data('anothertext'));//only for test, return undefined¿Hay algo mal con el código?