You have some things wrong in your code.
Let's start with HTML code.
When you need to interpolate an attribute, you must use v-bind. So you have two ways to do that. Using v-bind:attribute="expression"
or the shorthand :attribute="expression"
. Using attribute="{{ expression }}"
will definitely not work.
Another important thing, to use a custom attribute name, you should use data-custom-attribute-name
instead of data_custom-attribute-name
.
<div id="app">
<a
href="javascript:"
class="btn btn-info btn-xs"
@click="editModal"
:data-id="staff.id"
:data-my-amazing-custom-attribute="staff.name">
Click me!
</a>
</div>
Now, let's go to JS. From your question I couldn't know where the $staff variable comes from, so I made an adaptation to demonstrate.
new Vue({
el: '#app',
methods: {
editModal: function(event){
// Here you will be able to see all the
// custom attributes in camelCase
console.log(event.target.dataset);
console.log('ID:', event.target.dataset.id);
console.log('Name:', event.target.dataset.myAmazingCustomAttribute);
}
},
data () {
return {
staff: {
id: 'some id',
name: 'Name of my amazing custom attribute'
}
}
}
});
You can check a working version here: https://jsfiddle.net/6v3wyoh6/
Hope it helps!