Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ajax select2

$("#e7").select2({
    placeholder: "Search for a repository",
    minimumInputLength: 3,
    ajax: {
        url: "https://api.github.com/search/repositories",
        dataType: 'json',
        quietMillis: 250,
        data: function (term, page) { // page is the one-based page number tracked by Select2
            return {
                q: term, //search term
                page: page // page number
            };
        },
        results: function (data, page) {
            var more = (page * 30) < data.total_count; // whether or not there are more results available
 
            // notice we return the value of more so Select2 knows if more results can be loaded
            return { results: data.items, more: more };
        }
    },
    formatResult: repoFormatResult, // omitted for brevity, see the source of this page
    formatSelection: repoFormatSelection, // omitted for brevity, see the source of this page
    dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
    escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript execute function by string name 
Javascript :: node js post method 
Javascript :: cypress check element have attribute 
Javascript :: js loop to array backwards 
Javascript :: angular list contains property 
Javascript :: disabling submit button until all fields have values 
Javascript :: html2pdf example angular 
Javascript :: javascript how to select radio button 
Javascript :: copy text on click 
Javascript :: how the filter() function works javascript 
Javascript :: javascript remove query string from url 
Javascript :: oneerror javascript image 
Javascript :: math.min 
Javascript :: deploy vue js to shared hosting 
Javascript :: get previous year in javascript 
Javascript :: sanitizer content nodejs 
Javascript :: array every javascript 
Javascript :: create url with query parameters javascript 
Javascript :: js date in two weeks 
Javascript :: javascript move element to coordinates 
Javascript :: uncaught (in promise): both the table and dtoptions cannot be empty 
Javascript :: express server sockjs 
Javascript :: regex in mongo query 
Javascript :: javascript remove all element in array 
Javascript :: react-active link 
Javascript :: javascript vector 
Javascript :: vue toggle boolean on click 
Javascript :: regex all 
Javascript :: mongoBD update increment a value by 2 
Javascript :: select distinct on expressions must match initial order by expressions django 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =