Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    vuejs color filter with checkbox

    Knowledge Base
    1
    1
    680
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Keerthi last edited by Keerthi

      Hi,

      Can any one help me how to filter the certain products based on whether checkbox is clicked or not with vue.js and how to link up color filter to our products, actually I have created sample vuejs color filter with checkbox. Please find below is the code that need to paste in packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php

      Before @push('scripts')

      <div class="layered-wrapper">
      <layered></layered>
      </div>
      

      Paste below code In @push('scripts') of the same file

      <script type="text/x-template" id="layered-template">
              <div>
      
              <div v-for="cat in categoryList">
                <input type="checkbox" :id="cat" :value="cat" v-model="categories">
                <label :for="cat">@{{ cat }}</label>
                
              </div>
              <br>
              <span>You have chosen:  categories </span>
      
              <ul>
                <li v-for="item in selectedItems"> category: @{{item.category}} | name: @{{item.name}}</li>
              </ul>
              </div>
          </script>
          <script>
      Vue.component('layered', {
      
      template: '#layered-template',
      
      name: 'Checkbox',
          data() {
            return {
              categoryList: ['animal', 'fruit', 'clothes'],
              categories: [],
              items: [
                { id: '1', name: 'apple', description: 'description about product', category: 'fruit', },
                { id: '2', name: 'mango', description: 'description about product', category: 'fruit', },
                { id: '3', name: 'shoes', description: 'description about product', category: 'footwear', },
                { id: '4', name: 'shirt', description: 'description about product', category: 'clothes', },
                { id: '5', name: 'dog', description: 'description about product', category: 'animal', },
                { id: '6', name: 'cat', description: 'description about product', category: 'animal', },
              ],
            };
          },
          computed: {
            selectedItems: function () {
              return this.items.filter(function (item) {
                return this.categories.includes(item.category);
              }, this);
            },
          },
      
      
      });
      </script>
      

      I want this kind of output when we click on checkbox, please can anyone help me how to get this dynamic with the our products, actually I don't know vue.js.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post