Select2 uses a function to load result data. here’s a trivial example that creates choices that consist of user’s input repeated a number of times:

 

 

 

 

 

 

in order to take advantage of custom data loading Select2 should be attached to an input type='hidden' tag, otherwise data is parsed from select‘s option tags.

 

eg code:

  1. $(“#e5”).select2({
  2. minimumInputLength: 1,
  3. query: function (query) {
  4. var data = {results: []}, i, j, s;
  5. for (i = 1; i < 5; i++) {
  6. s = “”;
  7. for (j = 0; j < i; j++) {s = s + query.term;}
  8. data.results.push({id: query.term + i, text: s});
  9. }
  10. query.callback(data);
  11. }
  12. });

25 responses »

  1. d3 items says:

    Very interesting information!Perfect just what I was searching for!

  2. l-tyrosine says:

    Hi, i believe that i saw you visited my weblog thus i got here to “return the prefer”.I am trying to to find things to enhance my site!I suppose its good enough to make use of some of your concepts!!

  3. d3 gold says:

    Very interesting info!Perfect just what I was searching for!

  4. coconuts oil says:

    Greeting from across the ocean. interesting blog I will return for more.

  5. ltheanine says:

    I love your helpful article. topnotch information. I hope you write others. I will carry on reading

  6. nootropic says:

    Real great info can be found on this site.

  7. Very interesting info!Perfect just what I was searching for!

  8. Jailbreak says:

    Rattling superb information can be found on this website.

  9. Hi, i believe that i noticed you visited my blog so i came to “go back the prefer”.I’m trying to to find issues to improve my website!I suppose its ok to make use of a few of your ideas!!

  10. d3 gold says:

    Good Morning, I just stopped by to visit your site and thought I’d say thanks for having me.

  11. d3 items says:

    Greeting from across the world. interesting blog I shall return for more.

  12. jailbreak says:

    This blog has inspired me to start focusing on my own blog

  13. vitamins says:

    Rattling good info can be found on this weblog.

  14. notropics says:

    I love your insightful article. excellent stuff. I hope you produce others. I will continue reading

  15. I adored your insightful words. super contribution. I hope you release more. I will carry on reading

  16. nootropics says:

    Hello, i believe that i saw you visited my blog so i got here to “return the choose”.I am trying to in finding things to enhance my site!I assume its ok to make use of some of your concepts!!

  17. Hi, i believe that i saw you visited my website thus i got here to “return the want”.I’m trying to in finding issues to improve my web site!I assume its good enough to use a few of your ideas!!

  18. Howdy! This is kind of off topic but I need some help from an established blog. Is it hard to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about making my own but I’m not sure where to start. Do you have any tips or suggestions? With thanks

  19. aion kinah says:

    I considered sending this trackback incredible feature

  20. fitness says:

    thank you for sharing with us, I conceive this website truly stands out : D.

  21. best internet forum says:

    Only a smiling visitor here to share the love (:, btw outstanding pattern. “Competition is a painful thing, but it produces great results.” by Jerry Flint.

  22. Great web site you have here.. It’s hard to find excellent writing like yours these days. I seriously appreciate individuals like you! Take care!!

  23. best internet forum says:

    I always was interested in this subject and still am, thanks for posting .

As salam. Hi. Leave a Comment?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s