Troubleshooting: Unable to trigger click event on Vuejs component

Working with Vuejs and Vuikit components, I have set up the following structure:

<template>
    <div class="uk-scope">
        <vk-modal :show="isShow" v-if="config">
          <vk-modal-close @click="alert('hello!')" large></vk-modal-close>
          <vk-notification :messages.sync="messages"></vk-notification>
            <app-breadcrumb :current-view="currentView" />
            <!-- render the currently active component/page here -->
            <component v-bind:is="currentView"/>
        </vk-modal>
    </div>
</template>

My problem is that the close modal button does not seem to trigger the @click function.

While the parent component emits an event, I would like the close button to directly trigger something.

I attempted using @click.native="someFunction()", but it did not work!

Answer №1

I have not had the opportunity to use vuikit before, but based on their documentation, it seems like this is the correct way to close a modal. I would suggest removing the v-if="config" as it could potentially cause confusion in Vue.

<template>
    <div class="uk-scope">
        <vk-modal :show.sync="isShow">
          <vk-modal-close @click="isShow = false" large></vk-modal-close>
          <vk-notification :messages.sync="messages"></vk-notification>
            <app-breadcrumb :current-view="currentView" />
            <!-- render the currently active component/page here -->
            <component v-bind:is="currentView"/>
        </vk-modal>
    </div>
</template>

Answer №2

Did you attempt to implement @click.native="someFunction"? Keep in mind that this syntax does not include ().

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

Search for spaces and brackets in a file name, excluding the file extension using Regular Expressions

Currently utilizing javascript and I have a specific string let filename1 = "excluder version(1).pdf" Keep in mind that the extension may vary, like jpg or png I am looking to replace the original string with the desired outcome is it possible ...

What are your thoughts on implementing the model-view-controller pattern for a JavaScript game using Three.js?

As I work on a 3D game in three.js that is entirely frontend-based at the moment, I'm considering whether separating the model (state) and view is a wise decision. Currently, I directly manipulate the movement of objects by translating and rotating t ...

How to assign a value to a component variable using props in Vue.js

I am attempting to assign a props value to my component variable. Below is the code I'm working with: export default { props: { // eslint-disable-next-line vue/require-default-prop multiPaginatedTableTitle: { type: Stri ...

Is there a way to remove a specific object key from a JavaScript object?

One thing I would like to achieve is transforming a JSON structure. Let's start with an example like this: { "de": { "errors.de.i18n.js": { "errors": { "addcreditcard": "Wir konnten diese Karte nicht verifizier ...

Change classes of sibling elements using Angular 2

Imagine you have the following code snippet: <div id="parent"> <div class="child"> <div class="child"> <div class="child"> </div> I am looking to automatically assign the class active to the first child element. ...

Effect triggered upon scrolling to the top or bottom of the page

Would greatly appreciate your help in identifying errors in my script. Can someone point out where I might be going wrong? I am using two plugins - the first for custom scrollbar changes, and the second which I have cut and pasted into the first call. Bel ...

Oops! Looks like you forgot to include the "reducer" argument. It is necessary and should be either a function or an object of functions that can be passed to combineReducers

1 I'm currently working through the Redux tutorials on their website and I'm encountering an issue when trying to use combine reducers. When I run my code without using combine reducers, everything works fine. However, as soon as I include the s ...

Button color changes upon submission of form

Can anyone help me figure out how to change the color of a submit button after a form submission using Twitter Bootstrap 3? I have a form with multiple buttons serving as filters for my product page, but I can't seem to change the color of the selecte ...

Steps for deploying updates from a Laravel + Inertia + Vue3 application to a production server

I have been working on a project for a client, making changes to Vue and SCSS files. I need to deploy these changes to the live server, which is hosted on Digital Ocean with server-side rendering enabled. "private": true, "scripts& ...

What is the best way to bind the value of total when working with forms and the bind method?

I am working on a form where I need to pass the value of total. Regarding the total: I have successfully passed the value of the cart, which is an array. const [total, setTotal] = useState<number | undefined>(undefined); const calculateTotal = () ...

HMR: The webpack-hot-middleware is not refreshing my webpage

My Vue application, titled hello-world, is utilizing webpack-dev-middleware and webpack-hot-middleware. When running the application, it shows that it's connected in the console. However, after making changes to my main.js file, the following message ...

What steps should I follow to enable my bot to generate or duplicate a new voice channel?

I needed my bot to either create a new voice server or clone an existing one. The variable "voic" contains the ID of the voice channel. voic.voiceChannel.clone(undefined, true, false, 'Needed a clone') // example from ...

An alternative method for storing data in HTML that is more effective than using hidden fields

I'm trying to figure out if there's a more efficient method for storing data within HTML content. Currently, I have some values stored in my HTML file using hidden fields that are generated by code behind. HTML: <input type="hidden" id="hid1 ...

Prevent users from deleting options in Autocomplete by disabling the backspace key

I am currently working on implementing the Autocomplete component from Material-Ui library to allow users to select multiple options, but I want to restrict them from directly removing any of those options. One issue I've encountered is that users ca ...

Having trouble parsing a JSON object using the fetch method in React while trying to retrieve data from my database

While using fetch with the "get" method, I encountered an issue where passing the response from my SQL database to my object using useState results in an empty object. However, when I print the response data from my database through console logs, it shows ...

Tips for showcasing unprocessed JSON information on a webpage

Similar Question: JSON pretty print using JavaScript I am looking to present my raw JSON data on an HTML page similar to how JSONView displays it. Here is an example of my raw JSON data: { "hey":"guy", "anumber":243, "anobject":{ "whoa ...

Style the "focus" pseudo-class of an input element using Vue programmatically

Currently, I have been utilizing event listeners to manipulate the :focus pseudo-class of an input element: const element = document.getElementById("myElementID"); element.addEventListener("focus", (e) => { e.target.style.borderCo ...

What is the best way to retrieve information from an API and save it in an array within a MongoDB schema?

My current challenge involves querying an API in node.js, storing the obtained data in an array, and then pushing that array to a MongoDB schema. However, I am encountering difficulties as I am receiving an 'unhandledpromiserejection' warning err ...

Extract user's location using JavaScript and transfer it to PHP

My goal is to utilize JavaScript to retrieve the latitude and longitude, then compare it with the previous location, similar to how Facebook authenticates logins from different devices. To accomplish this, I have implemented 2 hidden fields which will capt ...

Anticipate the striking impact of Tapestry in JavaScript

Our app uses Tapestry 5.3.8, and Selenium 2.53.1 for integration tests. There are times when a Selenium test needs to wait for an action to complete, such as when Tapestry initiates an AJAX request. In such cases, the following code is used to wait for th ...