reacting to external value changes

Select2 can react to external value changes & keep its selection in-sync. this feature allows Select2 to work seamlessly with front-end frameworks that use data binding between ui components and model values.

this feature is only available when initSelection() function is provided in the options. this function is needed to map the choice ids set on the element to objects used by Select2. this function is set by default when Select2 is attached to aselect or when the tags helper function is used.

eg code:

  1. $(“#e13”).select2();
  2. $(“#e13_ca”).click(function() { $(“#e13”).val(“CA”).trigger(“change”); });
  3. $(“#e13_ak_co”).click(function() { $(“#e13”).val([“AK”,”CO”]).trigger(“change”); });

 

Select2 lifecycle

 

 

 

eg code:

  1. $(“#e14”).select2();
  2. $(“#e14_init”).click(function() { $(“#e14”).select2(); });
  3. $(“#e14_destroy”).click(function() { $(“#e14”).select2(“destroy”); });

 

Select2 Drag & Drop Sorting

Select2 supports drag & drop sorting of selected choices. Select2 doesn’t  itself provide the necessary code to perform dragging & dropping, instead it provides hooks that other libraries can use to provide the behavior. in this eg we are using JQuery UI’s sortable() plugin.

the sorting is only available when Select2 is attached to a hidden input field.

 

 

 

eg code:

  1. $(“#e15”).select2({tags:[“red”, “green”, “blue”, “orange”, “white”, “black”, “purple”, “cyan”, “teal”]});
  2. $(“#e15”).on(“change”, function() { $(“#e15_val”).html($(“#e15”).val());});
  3. $(“#e15”).select2(“container”).find(“ul.select2-choices”).sortable({
  4. containment: ‘parent’,
  5. start: function() { $(“#e15”).select2(“onSortStart”); },
  6. update: function() { $(“#e15”).select2(“onSortEnd”); }
  7. });

54 responses »

  1. nootropic says:

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

  2. salutations from over the sea. interesting article I will return for more.

  3. SAM-e says:

    Hello, i think that i saw you visited my blog so i came to “return the favor”.I’m trying to to find issues to enhance my website!I suppose its good enough to use some of your ideas!!

  4. nootropic says:

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

  5. nootropic says:

    You have mentioned very interesting points! ps nice site.

  6. jailbreak says:

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

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

  8. salutations from across the world. interesting post I will return for more.

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

  10. Aion Kinah says:

    I enjoyed your helpful blog. awesome information. I hope you produce others. I will continue reading

  11. nice site says:

    Rattling wonderful info can be found on this web site.

  12. jailbreak says:

    Hey, I just stopped in to visit your site and thought I’d say I enjoyed myself.

  13. jailbreak says:

    Hi, i think that i noticed you visited my weblog so i got here to “return the desire”.I’m trying to in finding issues to improve my site!I guess its ok to use some of your concepts!!

  14. vitamin says:

    I admired your wonderful blog. first class information. I hope you release others. I will continue reading

  15. You have noted very interesting details! ps nice web site.

  16. incontinence says:

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

  17. Tiny Skoog says:

    We love our Kindle Fire, but as many people have said it has some drawbacks when compared to the iPad, especially on size and power. But I’m impressed with the new specs of the Kindle Fire 2 with the 10inch screen. Some of the new specs are at kindlemad.com and I think they will be opening up pre-orders soon.

  18. l-tyrosine says:

    Hi, i believe that i noticed you visited my weblog so i came to “return the desire”.I am trying to to find issues to enhance my site!I suppose its adequate to use a few of your ideas!!

  19. Who gave you a blog!

  20. notropics says:

    Hi, i feel that i noticed you visited my weblog thus i got here to “go back the want”.I am trying to in finding issues to improve my website!I assume its ok to use some of your concepts!!

  21. picamilon says:

    Hello, I just stopped in to visit your blog and thought I’d say I had a great visit.

  22. Zune and iPod: Most people compare the Zune to the Touch, but after seeing how slim and surprisingly small and light it is, I consider it to be a rather unique hybrid that combines qualities of both the Touch and the Nano. It’s very colorful and lovely OLED screen is slightly smaller than the touch screen, but the player itself feels quite a bit smaller and lighter. It weighs about 2/3 as much, and is noticeably smaller in width and height, while being just a hair thicker.

  23. Cletus Popec says:

    I just could not depart your site before suggesting that I extremely enjoyed the standard information a person provide in your guests? Is gonna be back continuously in order to inspect new posts.

  24. Thanks for your your content – really interesting. We love our Kindle and the best site for tips and tricks is coolkindles.

  25. What did you think of the avengers

  26. I just added this blog site to my feed reader, great stuff. Can not get enough!

  27. Hello, i believe that i noticed you visited my weblog so i came to “return the desire”.I am attempting to find things to enhance my site!I assume its adequate to make use of a few of your ideas!!

  28. Ellis Snair says:

    Many thanks for your personal comments Cynthia. Understanding the time flow of one’s target audience can definitely improve results I have uncovered.

  29. hi, i just tried this software, by after i login using the username and password, it gives an error, it says:
    “Invalid account, Please try yet again! Register if you will not have an account.”
    i hope you help me.
    thanks.

  30. nootropics says:

    Hello, i believe that i saw you visited my blog so i came to “return the choose”.I am attempting to find issues to improve my website!I guess its ok to use some of your concepts!!

  31. nootropics says:

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

  32. Most of what you articulate is supprisingly legitimate and it makes me wonder why I hadn’t looked at this in this light before. Your article really did turn the light on for me personally as far as this particular topic goes. However there is 1 position I am not really too comfortable with so while I try to reconcile that with the central theme of the position, permit me see just what the rest of the visitors have to say.Very well done.

  33. Certainly with your thoughts here and that i love your blog! I’ve bookmarked it making sure that I can come back & read more in the foreseeable future.

  34. Hey, I just stopped in to visit your website and thought I’d say thanks for having me.

  35. Hello, I just stopped by to visit your site and thought I’d say I enjoyed myself.

  36. Troy Traub says:

    A blog like yours should be earning much money from adsense.’~::-

  37. aion kinah says:

    salutations respect your writing have a look of mine

  38. If you’re still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you’ll know which is right for you.

  39. Emery Dragon says:

    I’m completely cheerful to uncover this great site. I’d like to say thanks a lot for this excellent read. If you possible could add Stumbleupon button to your web page, it just might help you to reach a lot more people on the net. Kind regards

  40. Shanika says:

    Kilka kwestii wprowadzających w pomyłka czytelnika, mimo to generalnie dokładnie napisany. Nim wkroczysz na podany temat sprawdź wszelkie źródła bo nie wszystko co napisałeś to prawda.

  41. Normally I do not read article on blogs, however I wish to say that this write-up very pressured me to take a look at and do so! Your writing taste has been amazed me. Thanks, quite nice post.

  42. Przęsła ogrodzeniowe są bardzo wydajnym rozwiązaniem
    jeśli musimy zastosować montarz odpowiedniego dla Nas sposobu grodzeń, jest bardzo wydajny zarówno na terenie
    prywatnych działek, ale również przy najzwyklejszym ogrodzeniu plantacji oraz całych gospodarstw.
    Zstosowaniesiatki leśnej zapewnia zabezpieczenie przez
    amatorami cudzej własności. Główną cechą chzakterystyczną jest mnogość zastosowań.
    Przewagą nad innymi rozwiązaniami takiego rozwiąznia, jest też jego
    niska cena oraz prosty montarz. Polecam.

  43. It’s not my first time to go to see this site, i am visiting this site dailly and get fastidious data from here daily.

  44. sosnowiec.pl says:

    Zaręczyny już niebawem więc przyszedł godzina aby odszukać ten fenomenalny i prześliczny pierścionek zaręczynowy.
    W dzisiejszych czasach wybór pierścionka zaręczynowego zależy
    od życzeń narzeczonej przyszłego narzeczonego oraz od
    zasobności jego portfela. Propozycje sklepów jubilerskich jest
    bardzo zróżnicowana. Jaki pierścionek zaręczynowy wybrać?

    Zwyczaj mówi o złotym, to nie budzi u nikogo żadnych wątpliwości.
    Jeżeli przyszła wybranka serca nie lubi żółtego złota można zdecydować się na białe złoto, które równie elegancko i
    adekwatnie wygląda. Biżuteria może też być wykonana z dwóch kruszców np.
    białego i żółtego złota lub żółtego złota i
    srebra co w połączeniu z rubinem i diamentami zauroczy naszą wybrankę.
    Dobrym pomysłem na poszukiwanie pierścionka jest sklep online.
    Takie rozwiązanie jest dogodne, dlatego, że możemy komfortowego obejrzenia
    i porównania wyrobów.

  45. Thank you for helping out, superb information. “You must do the things you think you cannot do.” by Eleanor Roosevelt.

  46. Avalanche is a rip off. Check it out. Check out all the people that it has ripped off.

  47. Good post. I learn something new and challenging on sites I stumbleupon on a daily basis. It’s always exciting to read articles from other authors and practice something from other sites.

  48. Way cool! Some very valid points! I appreciate you writing this write-up and the rest of the website is also really good.

  49. A matter near to my heart thanks, do you have a Facebook page for your website?

  50. website says:

    Trackback Priority…

    Wonderful website. A lot of helpful info here. I am sending it to some buddies ans also sharing in delicious. And obviously, thank you for your effort!…

  51. I like this site very much so much good info . “It’s a poor sort of memory that only works backward.” by Lewis Carroll.

  52. Guten tag! Hohoho! I’m not Deuche, but had ya going! Nice site neway, I love what you wrote.

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