windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Creating Vue Search Bar | How to hide/show data based on input?

Asked By: user7531085

I am creating a dynamic search bar that will filter a sidebar full of names based on user input. However, I am having trouble temporarily hiding and showing data based on the search bar’s value on keyup. What is the best way to achieve this the “Vue way”?

On keyup, I want to filter through all of the this.people data and only show names that contain the value of the search input.

Below is what my code looks like

_x000D_

_x000D_

Vue.component('sidebar',{_x000D_
    props: ['people', 'tables'],_x000D_
    data: () => {_x000D_
        return {_x000D_
            fullName: ''_x000D_
        }_x000D_
    },_x000D_
    computed: {_x000D_
        computed() {_x000D_
            return [this.people, this.tables].join()_x000D_
        }_x000D_
    },_x000D_
    template: _x000D_
    `_x000D_
        <div id="sidebarContain" v-if="this.people">_x000D_
            <input id="sidebar-search" type="text" placeholder="Search..." @keydown="searchQuery">_x000D_
            <select id="sidebar-select" @change="sidebarChanged">_x000D_
                <option value="AZ">A-Z</option>_x000D_
                <option value="ZA">Z-A</option>_x000D_
                <option value="notAtTable">No Table</option>_x000D_
                <option value="Dean's Guest">Dean's Guest</option>_x000D_
                <option value="BOO | VIP">BOO | VIP</option>_x000D_
            </select>_x000D_
            <div v-for="person in people" :class="[{'checked-in': isCheckedIn(person)}, 'person']" :id="person.id" :style="calcRegColor(person)">_x000D_
                <span v-if="person.table_name">{{person.first_name + ' ' + person.last_name + ' - ' + person.table_name}}</span>_x000D_
                <span v-else>{{person.first_name + ' ' + person.last_name}}</span>_x000D_
            </div>_x000D_
        </div>_x000D_
    `,_x000D_
    methods: {_x000D_
        isCheckedIn(person) {_x000D_
           return person.reg_scan == null ? true : false;_x000D_
        },_x000D_
        isHidden(person)_x000D_
        {_x000D_
            console.log("here");_x000D_
        },_x000D_
        calcRegColor(person)_x000D_
        {_x000D_
            switch(person.registration_type)_x000D_
            {_x000D_
                case "Dean's Guest" :_x000D_
                    return {_x000D_
                        color: 'purple'_x000D_
                    }_x000D_
                    break;_x000D_
                case "BOO | VIP" :_x000D_
                    return {_x000D_
                        color: 'brown'_x000D_
                    }_x000D_
                    break;_x000D_
                case "Student" :_x000D_
                    return {_x000D_
                        color: 'green'_x000D_
                    }_x000D_
                    break;_x000D_
                case "Faculty":_x000D_
                case "Staff":_x000D_
                    return {_x000D_
                        color: 'blue'_x000D_
                    }_x000D_
                    break;_x000D_
                case "Alumni Club Leader":_x000D_
                    return {_x000D_
                        color: 'gold'_x000D_
                    }_x000D_
                    break;_x000D_
                case "Table Guest" :_x000D_
                    return {_x000D_
                        color: 'pink'_x000D_
                    }_x000D_
                    break;_x000D_
                default: _x000D_
                    return {_x000D_
                        color: 'black'_x000D_
                    }_x000D_
            }_x000D_
        }_x000D_
    },_x000D_
    watch: {_x000D_
        computed() {_x000D_
            console.log("People and Tables Available");_x000D_
        }_x000D_
    }_x000D_
});_x000D_
_x000D_
var app = new Vue({_x000D_
  el: '#main',_x000D_
  data: {_x000D_
    tables: {},_x000D_
    people: [],_x000D_
    currentAlerts: [],_x000D_
    lastDismissed: []_x000D_
  },_x000D_
  methods: {_x000D_
    loadTables() {_x000D_
        $.ajax({_x000D_
          method: 'POST',_x000D_
          dataType: 'json',_x000D_
          url: base_url + 'users/getTableAssignments/' + event_id_x000D_
        }).done(data => {_x000D_
          this.tables = data; _x000D_
        });_x000D_
    },_x000D_
    loadPeople() {_x000D_
        $.ajax({_x000D_
            method: 'POST',_x000D_
            dataType: 'json',_x000D_
            url: base_url + 'users/getParticipants2/' + event_id_x000D_
        }).done(data => {_x000D_
            this.people = data;_x000D_
            this.sortSidebar(this.people);_x000D_
        });_x000D_
    },_x000D_
    loadCurrentAlerts() {_x000D_
        $.ajax({_x000D_
            method: 'POST',_x000D_
            dataType: 'json',_x000D_
            url: base_url + 'alerts/getAlerts/' + event_id_x000D_
        }).done(data => {_x000D_
            this.currentAlerts = data;_x000D_
        });_x000D_
    },_x000D_
    loadLastDismissed(num = 15)_x000D_
    {_x000D_
        $.ajax({_x000D_
            method: 'POST',_x000D_
            dataType: 'json',_x000D_
            url: base_url + 'alerts/getLastDismissed/' + event_id + '/' + num_x000D_
        }).done(data => {_x000D_
            this.lastDismissed = data;_x000D_
        });_x000D_
    },_x000D_
    setRefresh() {_x000D_
        setInterval(() => {_x000D_
            console.log("Getting People and Tables");_x000D_
            this.loadPeople();_x000D_
            this.loadTables();_x000D_
        }, 100000);             _x000D_
    },_x000D_
    makeTablesDraggable() {_x000D_
        $(document).on("mouseenter", '.table', function(e){_x000D_
         var item = $(this); _x000D_
         //check if the item is already draggable_x000D_
         if (!item.is('.ui-draggable')) {_x000D_
                 //make the item draggable_x000D_
                 item.draggable({_x000D_
                    start: (event, ui) => {_x000D_
                        console.log($(this));_x000D_
                    }_x000D_
                 });_x000D_
          }_x000D_
        });_x000D_
    },_x000D_
    makePeopleDraggable() {_x000D_
         $(document).on("mouseenter", '.person', function(e){_x000D_
         var item = $(this); _x000D_
         //check if the item is already draggable_x000D_
         if (!item.is('.ui-draggable')) {_x000D_
                 //make the item draggable_x000D_
            item.draggable({_x000D_
                appendTo: 'body',_x000D_
                containment: 'window',_x000D_
                scroll: false,_x000D_
                helper: 'clone',_x000D_
                start: (event, ui) => {_x000D_
                    console.log($(this));_x000D_
                }_x000D_
            });_x000D_
          }_x000D_
        });       _x000D_
    }_x000D_
    makeDroppable() {_x000D_
        $(document).on("mouseenter", ".dropzone, .table", function(e) {_x000D_
            $(this).droppable({_x000D_
                drop: function(ev, ui) {_x000D_
                    console.log("Dropped in dropzone");_x000D_
                }_x000D_
            });_x000D_
        });_x000D_
    }_x000D_
 },_x000D_
  mounted() {_x000D_
    this.loadTables();_x000D_
    this.loadPeople();_x000D_
    this.loadCurrentAlerts();_x000D_
    this.loadLastDismissed();_x000D_
    this.setRefresh();_x000D_
    this.makeTablesDraggable();_x000D_
    this.makePeopleDraggable();_x000D_
    this.makeDroppable();_x000D_
  }

_x000D_

<head>_x000D_
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">_x000D_
    <a href="https://code.jquery.com/jquery-3.1.1.min.js">https://code.jquery.com/jquery-3.1.1.min.js</a>_x000D_
    <a href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js">https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js</a>_x000D_
  <a href="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.js">https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.js</a> _x000D_
</head>_x000D_
<div id="app">_x000D_
    <sidebar :people="people" :tables="tables"></sidebar>_x000D_
</div>

_x000D_

_x000D_

x000D


Solution

Answered By: Anonymous

You can change the people property in sidebar into a computed property, which will be calculated based on user’s input.

So change the sidebar code to

<div v-for="person in filteredPeople" :class="[{'checked-in': isCheckedIn(person)}, 'person']" :id="person.id" :style="calcRegColor(person)">
  <span v-if="person.table_name">{{person.first_name + ' ' + person.last_name + ' - ' + person.table_name}}</span>
  <span v-else>{{person.first_name + ' ' + person.last_name}}</span>
</div>

and add a computed property

computed: {
    filteredPeople () {
        // Logic to filter data
    } 
}

techinplanet staff

instagram volgers kopen volgers kopen buy windows 10 pro buy windows 11 pro


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort Çanakkale escort Aydın escort Muğla escort Tekirdağ escort Manisa escort Balıkesir escort Trabzon escort Elazığ escort Ordu escort Kütahya escort Isparta escort Rize escort Kahramanmaraş escort Yalova escort Giresun escort Yozgat escort Tokat escort Şanlıurfa escort Sivas escort Batman escort Erzurum escort Sinop escort Kırşehir escort Karaman escort Kırıkkale escort Bolu escort Amasya escort Niğde escort Uşak escort Edirne escort Çorum escort Osmaniye escort Zonguldak escort Van escort Erzincan escort Söke escort Bodrum escort Çerkezköy escort Akhisar escort Bandırma escort Ayvacık escort Akçaabat escort Karakoçan escort Altınordu escort Tavşanlı escort Eğirdir escort Ardeşen escort Afşin escort Altınova escort Bulancak escort Sorgun escort Erbaa escort Viranşehir escort Zara escort Kozluk escort Aziziye escort Ayancık escort Kaman escort Ermenek escort Keskin escort Gerede escort Göynücek escort Bor escort Banaz escort Havsa escort Osmancık escort Bahçe escort Alaplı escort Başkale escort Kemah escort Nazilli escort Fethiye escort Çorlu escort Alaşehir escort Altıeylül escort Biga escort Araklı escort Kovancılar escort Fatsa escort Simav escort Yalvaç escort Çayeli escort Dulkadiroğlu escort Çiftlikköy escort Espiye escort Sarıkaya escort Niksar escort Suruç escort Yıldızeli escort Sason escort Horasan escort Boyabat escort Mucur escort Sarıveliler escort Yahşihan escort Göynük escort Gümüşhacıköy escort Çamardı escort Eşme escort İpsala escort Sungurlu escort Hasanbeyli escort Çaycuma escort İpekyolu escort Refahiye escort Kuşadası escort Marmaris escort Süleymanpaşa escort Turgutlu escort Susurluk escort Gelibolu escort Of escort Ünye escort Domaniç escort Fındıklı escort Elbistan escort Çınarcık escort Tirebolu escort Akdağmadeni escort Turhal escort Eyyübiye escort Suşehri escort Yakutiye escort Gerze escort Mengen escort Merzifon escort Ulukışla escort Sivaslı escort Keşan escort Kadirli escort Ereğli escort Özalp escort Tercan escort Efeler escort Didim escort Çine escort Dalaman escort Menteşe escort Milas escort Ortaca escort Seydikemer escort Ergene escort Kapaklı escort Malkara escort Salihli escort Şehzadeler escort Soma escort Yunusemre escort Ayvalık escort Bigadiç escort Burhaniye escort Gönen escort Karesi escort Çan escort Yenice escort Ortahisar escort Yomra escort Perşembe escort Pazar escort Onikişubat escort Pazarcık escort Türkoğlu escort Eynesil escort Görele escort Piraziz escort Yağlıdere escort Çayıralan escort Boğazlıyan escort Zile escort Siverek escort Karaköprü escort Haliliye escort Akçakale escort Şarkışla escort Gemerek escort Oltu escort Palandöken escort Mudurnu escort Suluova escort Taşova escort Toprakkale escort Kilimli escort Tuşba escort Üzümlü escort