Creating a dynamic multi-choice dropdown list with Django and Vue.js

I have been attempting to implement the Vue.js multiselect component from the following link:

However, I am encountering an issue where instead of the expected multiselect dropdown, the output is not as desired and looks like this:

https://i.sstatic.net/if0d7.png

Here is the code I am using:

HTML:

<div id="app">
  <button @click="toggle">open and close later
  </button>
    <pre>{{ isOpen }}</pre>
    <multiselect
        ref="multiselect"
        v-model="value"
        :options="options"
        :multiple="true"
        track-by="library"
        :custom-label="customLabel"
        @close="isOpen = false"
        @open="isOpen = true"
    >
  </multiselect>
</div>

Libraries used (included in code):

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="067073632b6b736a726f75636a636572463428372836">[email protected]</a>"></script>
<link rel="stylesheet" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="275152420a4a524b534e54424b4"b</a>/dist/vue-multiselect.min.css">

Script used (placed at the bottom of the page):

<script>
        new Vue({
        components: {
        Multiselect: window.VueMultiselect.default
        },
        data: {
        isOpen: false,
        value: { language: 'JavaScript', library: 'Vue-Multiselect' },
        options: [
            {   language: 'JavaScript', library: 'Vue.js' },
          { language: 'JavaScript', library: 'Vue-Multiselect' },
          { language: 'JavaScript', library: 'Vuelidate' }
        ]
        },
      methods: {
        customLabel (option) {
          return `${option.library} - ${option.language}`
        },
        toggle () {
          this.$refs.multiselect.$el.focus()

          setTimeout(() => {
            this.$refs.multiselect.$refs.search.blur()
          }, 400)
        }
      }
    }).$mount('#app')
</script>

Answer №1

Discover the most comprehensive selection solution for Vue.js 2.0, completely free of jQuery.

If you are currently utilizing vue 1.0

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>

You must upgrade to version 2

Additionally, check the console for any errors and address them accordingly

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Solving the Challenge of URL Issue in Ajax Call to MVC Controller

I have searched extensively for a solution to my jQuery/MVC problem, but haven't found one that works. Here is the JavaScript code I am using: $.ajax({ type: "POST", url: '@Url.Action("Search","Controller")& ...

Trigger a modal dialog using the event bus event

I have successfully created a backend and now I am working on building the frontend using Vue.js. However, as a beginner in Vue.js, I am facing challenges in getting it to function as desired due to some gaps in my understanding of basic concepts. It would ...

Dealing with error handling in NUXT using asyncData and Vue actions

The URL I am trying to access is http://mywebsite.com/[category that doesn't exist]. Despite the code snippet provided below, I am unable to reach the catch block in asyncData. async asyncData({ params, store }) { try { await store.dispatch(&ap ...

Real-time data feeds straight from JSON

Currently, I have a JSON file that is generated dynamically and it contains match information along with a unique id. This JSON data is categorized into live, upcoming, and recent arrays. Being new to Javascript, I am unsure about the best approach to crea ...

Tips for transforming list items into an array of strings

let typeList="[Product,Task,Invoice,Media,Store]"; I need to transform the string above into an array like this:- let typeList=["Product","Task","Invoice","Media","Store"]; Any help with this is greatly appreciated. ...

Maximizing the potential of vue.js and firebase through proper directory organization

After installing firebase, the 'public' folder and 'index.html' are automatically created. I'm facing confusion regarding where to place the 'public' folder within the current vue project file structure. The 'localho ...

Utilizing jQuery UI datepicker as a fallback in absence of HTML5 native date input type

Although <input type="date"> is not commonly used for desktop, it is the preferred method for mobile devices. I am attempting to incorporate the fallback code located at the end of this section: <form> <input type="date"> </form&g ...

How to stop AngularJS onClick event from causing scroll to jump to top of

As I work on developing a website using Angular JS and Bootstrap, I encountered an issue with the hamburger menu button on my homepage. Whenever I scroll halfway down the page and click the hamburger icon, it automatically scrolls me back to the top of the ...

Step-by-step guide on building a mat-table with nested attributes as individual rows

Here is the data structure I am working with: const families = [ { name: "Alice", children: [ { name: "Sophia" }, { name: "Liam" ...

Exploring a section of a react-chartjs Pie chart

I'm currently exploring how to create a static Pie chart using react-chartjs-2. Wanting to make one slice stand out more than the others, I aim to have it appear larger: https://i.sstatic.net/rRTvN.png My focus is on accessing a specific slice in th ...

Achiever.js - Incorporating incremental progress with half stars instead of whole stars

Hello there! I've been utilizing Rater.js in my current project, and so far it has provided me with satisfactory results. However, I have encountered a particular issue that I am struggling to resolve on my own. It would be greatly appreciated if you ...

What is the preferred approach in JavaScript: having a single large file or multiple smaller files?

Having a multitude of JavaScript files loaded on a single page can result in decreased performance. My inquiry is this: Is it preferable to have individual files or combine them into one JavaScript file? If consolidating all scripts into one file is the ...

Tips for choosing elements based on a specific attribute (such as fill color) in D3.js using the SelectAll method

I have various sets of circles on a map - 10 red circles, 10 blue circles, and 10 green circles. Is there a way to use d3 selectAll or select to specifically choose only the red circles? Are there any alternative methods for achieving this? The color of ...

Partial implementation of jQuery datepicker feature facing technical issues

Greetings, I have a functional datepicker implemented in my code as follows: <link rel="stylesheet" href="uidatepicker/themes/blitzer/jquery.ui.all.css"> <script src="uidatepicker/jquery-1.5.1.js"></script> <script src="uidate ...

Can you retrieve the second value using JSON.stringify?

Currently implementing JSON.stringify(data.message) which returns the following value: [ { "code":"PasswordTooShort", "description":"Passwords must be at least 6 characters." } ] I aim to extract the description value for my alert message ...

I encountered a permission denied error when trying to enter DEBUG=app ./bin/www in Node.js

After renaming 'my-application' to just 'app', I encountered an issue when running the DEBUG command in the terminal: I used DEBUG=app ./bin/www Originally, it was named 'my-application' as created by express. However, after ...

Modify MUI's ListItemText component by targeting a specific span to implement customized styles using the useStyle hook

It's quite perplexing that although this is a straightforward task in regular CSS, it must be accomplished through MUI's useStyles for some peculiar reason. Essentially, I possess a ListItem containing a ListItemText. It appears as follows: cons ...

What is the best way to insert HTML elements onto a webpage and retrieve them in an asp.net environment?

Greetings, For the past day, I've been attempting to dynamically add elements to a web page using Visual Studio and access their values. Either I'm overthinking things, being foolish, or there just isn't a straightforward way to achieve wha ...

Discover the complete guide on incorporating a JavaScript library with additional dependencies in Angular 2

I am a beginner with angular 2 and I am attempting to integrate the Miso Dataset JavaScript library into my angular 2 project. The Miso library requires other JavaScript libraries as dependencies. Although I have included all the necessary JavaScript file ...

Ensuring Package Security in NodeJS and NPM

Given the immense popularity of NodeJS and how NPM operates, what measures can be taken to prevent the installation of insecure or malware-laden packages? Relying solely on user feedback from sources like StackOverflow or personal blogs seems to leave a si ...