loadThumbnailOptions(url, field) {
      field.select2({
          ajax: { // Use the jQuery.ajax wrapper provided by Select2
              url: url,
              dataType: "json",
              results: function(data, page) {
                return { results: data }
              },
              data: (term, page) => {
                return {
                  q: term, // search term
                  page: page
                };
              },
          },
          initSelection: function(element, callback) {
              // the input tag has a value attribute preloaded that points to a preselected repository's id
              // this function resolves that id attribute to an object that select2 can render
              // using its formatResult renderer - that way the repository name is shown preselected
              callback({ text: $(element).data('text') })
          }
      })
  }
// Dynamically load the file options into the "Thumbnail" select field.
Dynamically load the file options into the "Thumbnail" select field.
Dynamically load the file options into the " Thumbnail " select field .
loadThumbnailOptions(url, field) {
      field.select2({
          ajax: { 
              url: url,
              dataType: "json",
              results: function(data, page) {
                return { results: data }
              },
              data: (term, page) => {
                return {
                  q: term, 
                  page: page
                };
              },
          },
          initSelection: function(element, callback) {
              callback({ text: $(element).data('text') })
          }
      })
  }
loadThumbnailOptions ( url , field ) { field . select2 ( { ajax : { url : url , dataType : "json" , results : function ( data , page ) { return { results : data } } , data : ( term , page ) => { return { q : term , page : page } ; } , } , initSelection : function ( element , callback ) { callback ( { text : $ ( element ) . data ( 'text' ) } ) } } ) }
Dynamically load the file options into the "Thumbnail" select field.
Dynamically load the file options into the " Thumbnail " select field .
// Use the jQuery.ajax wrapper provided by Select2 // search term // the input tag has a value attribute preloaded that points to a preselected repository's id // this function resolves that id attribute to an object that select2 can render // using its formatResult renderer - that way the repository name is shown preselected