Select2 Loading remote data Example not working -


this example not working @ all.. can please create in jfiddle????

here example site. https://select2.github.io/examples.html thank help!!!

enter image description here

found answer this. see below example. hope helps others!

here fiddle

here script :

function formatrepo (repo) {     if (repo.loading) return repo.text;      var markup = '<div class="clearfix">' +     '<div class="col-sm-1">' +     '<img src="' + repo.owner.avatar_url + '" style="max-width: 100%" />' +     '</div>' +     '<div clas="col-sm-10">' +     '<div class="clearfix">' +     '<div class="col-sm-6">' + repo.full_name + '</div>' +     '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + repo.forks_count + '</div>' +     '<div class="col-sm-2"><i class="fa fa-star"></i> ' + repo.stargazers_count + '</div>' +     '</div>';      if (repo.description) {       markup += '<div>' + repo.description + '</div>';     }      markup += '</div></div>';      return markup;   }    function formatreposelection (repo) {     return repo.full_name || repo.text;   }  $(document).ready(function(){      $(".js-data-example-ajax").select2({       ajax: {         url: "https://api.github.com/search/repositories",         datatype: 'json',         delay: 250,         data: function (params) {           return {             q: params.term, // search term             page: params.page           };         },         processresults: function (data, page) {           // parse results format expected select2.           // since using custom formatting functions not need           // alter remote json data           return {             results: data.items             };         },         cache: true       },       escapemarkup: function (markup) { return markup; }, // let our custom formatter work       minimuminputlength: 1,       templateresult: formatrepo, // omitted brevity, see source of page        templateselection: formatreposelection // omitted brevity, see source of page        });   });    

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -