calling method dynamically through variables in vuejs

In Javascript if you are an object like this :

const foo = {
    bar() {},
    baz() {}
};

To call this "dynamicly" you should type

foo['bar']()
foo['baz']()

So, in your case, instead of :

this.[type]()

You should type :

this[type]()

Object could be manipulated like array index but, in this case, indexes are juste the fields

Warning : Your $.droppable().drop function is not correctly binded. So, at this time, the this is not the VueJS component :

  • in basics functions/methods of your vuejs component use the es6 functions fields (like your mounted, ...).
  • Inside this functions, use arrow function to kepp the right context for this. In this example, your drop function must be an arrow function to work correctly

you just think i pass the function as a dynamic.

I pass the function name as a "saveRecord".

try this way. It works well for me :)

var mydynamic_Function_Name = "saveRecord";
this[mydynamic_Function_Name]();