@@ -456,7 +456,225 @@ <h2>Local Data Search with custom propertyToSearch, resultsFormatter and tokenFo
456456 </ script >
457457 </ div >
458458
459+ < h2 > Change propertyToSearch anytime</ h2 >
460+ < div >
461+ < input type ="text " id ="demo-input-change-propertytosearch-anytime " name ="blah " />
462+ Search by :< input type ="radio " checked ="checked " name ="search_key " value ="first_name " /> First Name
463+ < input type ="radio " name ="search_key " value ="last_name " /> Last Name
464+ < input type ="radio " name ="search_key " value ="email " /> Email
465+ < input type ="radio " name ="search_key " value ="url " /> Url < br />
466+ < input type ="button " value ="Submit " />
467+ < script type ="text/javascript ">
468+ $ ( document ) . ready ( function ( ) {
469+ $ ( 'input[name="search_key"]' ) . click ( function ( ) {
470+ $ ( "#demo-input-change-propertytosearch-anytime" ) . tokenInput ( "setOptions" , { propertyToSearch : $ ( this ) . val ( ) , hintText : "Type " + $ ( this ) . val ( ) + " here to search" } ) ;
471+ } ) ;
459472
473+ $ ( "#demo-input-change-propertytosearch-anytime" ) . tokenInput ( [ {
474+ "id" : 1 ,
475+ "first_name" : "Arthur" ,
476+ "last_name" : "Godfrey" ,
477+ "email" : "arthur_godfrey@nccu.edu" ,
478+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
479+ } ,
480+ {
481+ "id" : 2 ,
482+ "first_name" : "Adam" ,
483+ "last_name" : "Johnson" ,
484+ "email" : "wravo@yahoo.com" ,
485+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
486+ } ,
487+ {
488+ "id" : 3 ,
489+ "first_name" : "Jeff" ,
490+ "last_name" : "Johnson" ,
491+ "email" : "bballnine@hotmail.com" ,
492+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
493+ } ,
494+ {
495+ "id" : 4 ,
496+ "first_name" : "Adriana" ,
497+ "last_name" : "Jameson" ,
498+ "email" : "adriana.jameson@gmail.com" ,
499+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
500+ } ,
501+ {
502+ "id" : 5 ,
503+ "first_name" : "Adriano" ,
504+ "last_name" : "Pooley" ,
505+ "email" : "adrianolpooley@lautau.com.br" ,
506+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
507+ } ,
508+ {
509+ "id" : 6 ,
510+ "first_name" : "Alcir" ,
511+ "last_name" : "Reis" ,
512+ "email" : "alcirreis@yahoo.com" ,
513+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
514+ } ,
515+ {
516+ "id" : 7 ,
517+ "first_name" : "Jack" ,
518+ "last_name" : "Cunningham" ,
519+ "email" : "jcunningham@hotmail.com" ,
520+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
521+ } ,
522+ {
523+ "id" : 8 ,
524+ "first_name" : "Alejandro" ,
525+ "last_name" : "Forbes" ,
526+ "email" : "alejandforbes@gmail.com" ,
527+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
528+ } ,
529+ {
530+ "id" : 9 ,
531+ "first_name" : "Alessandra" ,
532+ "last_name" : "Mineiro" ,
533+ "email" : "alc_mineiro@aol.com" ,
534+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
535+ } ,
536+ {
537+ "id" : 10 ,
538+ "first_name" : "Alex" ,
539+ "last_name" : "Frazo" ,
540+ "email" : "alex.frazo@yahoo.com" ,
541+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
542+ } ,
543+ {
544+ "id" : 11 ,
545+ "first_name" : "Alexandre" ,
546+ "last_name" : "Crawford" ,
547+ "email" : "xandycrawford@gmail.com" ,
548+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
549+ } ,
550+ {
551+ "id" : 12 ,
552+ "first_name" : "Alexandre" ,
553+ "last_name" : "Lalwani" ,
554+ "email" : "alexandrelalwani@globo.com" ,
555+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
556+ } ,
557+ {
558+ "id" : 13 ,
559+ "first_name" : "Alexandre" ,
560+ "last_name" : "Jokos" ,
561+ "email" : "alex.jokos@gmail.com.br" ,
562+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
563+ } ,
564+ {
565+ "id" : 14 ,
566+ "first_name" : "Alexandre" ,
567+ "last_name" : "Paro" ,
568+ "email" : "alexandre.paro@uol.com.br" ,
569+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
570+ } ,
571+ {
572+ "id" : 15 ,
573+ "first_name" : "Andre" ,
574+ "last_name" : "Niemeyer" ,
575+ "email" : "a.niemeyer@globo.com" ,
576+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
577+ } ,
578+ {
579+ "id" : 16 ,
580+ "first_name" : "Alyssa" ,
581+ "last_name" : "Fortes" ,
582+ "email" : "afort287@yahoo.com" ,
583+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
584+ } ,
585+ {
586+ "id" : 17 ,
587+ "first_name" : "Amit" ,
588+ "last_name" : "Alvarenga" ,
589+ "email" : "amit.alva@gmail.com" ,
590+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
591+ } ,
592+ {
593+ "id" : 18 ,
594+ "first_name" : "Ana Bia" ,
595+ "last_name" : "Borges" ,
596+ "email" : "abborges@gmail.com" ,
597+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
598+ } ,
599+ {
600+ "id" : 19 ,
601+ "first_name" : "Ana" ,
602+ "last_name" : "Akamine" ,
603+ "email" : "ana.akamine@uol.com.br" ,
604+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
605+ } ,
606+ {
607+ "id" : 20 ,
608+ "first_name" : "Anderson" ,
609+ "last_name" : "Tovoros" ,
610+ "email" : "alvarenga.tovoros@gmail.com" ,
611+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
612+ } ,
613+ {
614+ "id" : 21 ,
615+ "first_name" : "Andre" ,
616+ "last_name" : "Borges" ,
617+ "email" : "andreborges@hotmail.com" ,
618+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
619+ } ,
620+ {
621+ "id" : 22 ,
622+ "first_name" : "Andre" ,
623+ "last_name" : "Wexler" ,
624+ "email" : "andre.wexler@aol.com.br" ,
625+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
626+ } ,
627+ {
628+ "id" : 23 ,
629+ "first_name" : "Andre" ,
630+ "last_name" : "Williams" ,
631+ "email" : "awilly@yahoo.com" ,
632+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
633+ } ,
634+ {
635+ "id" : 24 ,
636+ "first_name" : "Andre" ,
637+ "last_name" : "Sanford" ,
638+ "email" : "andre.sanford@gmail.com" ,
639+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
640+ } ,
641+ {
642+ "id" : 25 ,
643+ "first_name" : "Andre" ,
644+ "last_name" : "Wayne" ,
645+ "email" : "andrewayne@uol.com.br" ,
646+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
647+ } ,
648+ {
649+ "id" : 26 ,
650+ "first_name" : "Andre" ,
651+ "last_name" : "Jackson" ,
652+ "email" : "andre.jackson@yahoo.com" ,
653+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
654+ } ,
655+ {
656+ "id" : 27 ,
657+ "first_name" : "Andre" ,
658+ "last_name" : "Jolly" ,
659+ "email" : "andre.jolly@uol.com.br" ,
660+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
661+ } ,
662+ {
663+ "id" : 28 ,
664+ "first_name" : "Andre" ,
665+ "last_name" : "Henderson" ,
666+ "email" : "andre.henderson@globo.com" ,
667+ "url" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png"
668+ }
669+ ] , {
670+ propertyToSearch : "first_name" ,
671+ resultsFormatter : function ( item ) { return "<li>" + "<img src='" + item . url + "' title='" + item . first_name + " " + item . last_name + "' height='25px' width='25px' />" + "<div style='display: inline-block; padding-left: 10px;'><div class='first_name'>" + item . first_name + " " + item . last_name + "</div><div class='email'>" + item . email + "</div><div class='url'>" + item . url + "</div></div></li>" } ,
672+ tokenFormatter : function ( item ) { return "<li><p>" + item . first_name + " " + item . last_name + "</p></li>" } ,
673+ } ) ;
674+ } ) ;
675+ </ script >
676+ </ div >
677+
460678 < h2 > Start disabled</ h2 >
461679 < div >
462680 < input type ="text " id ="demo-input-disabled " name ="blah " />
0 commit comments