Calling a function with parameters
See original GitHub issueI try to pass a parameter for the function called when clicking the button, but I figured out that this doesn’t work. Is it there any workaround in order to pass parameters to the function and still have the spinner working?
<button class="btn btn-default" @click="test(param1)" v-promise-btn>Save</button>
Thank you
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Python Functions - W3Schools
A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a...
Read more >6.3. Function Arguments and Parameters
Arguments are the values passed from a function call (i.e., they are the values appearing inside the parentheses of the call) and are...
Read more >How to execute a method passed as parameter to function
You can just call it as a normal function: function myfunction(param1, callbackfunction) { //do processing here callbackfunction(); }.
Read more >Python Function Examples – How to Declare and Invoke with ...
Type the function name. The function name has to be followed by parentheses. If there are any required arguments, they have to be...
Read more >Function.prototype.call() - JavaScript - MDN Web Docs - Mozilla
With call() , you can assign an arbitrary value as this when calling an existing function, without first attaching the function to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @STUkh @tradingstratagem
I can confirm the issue that was reported, and here is a reproducing jsfiddle: https://jsfiddle.net/rd5ef4t1/1/
I think there was a misunderstanding on the issue. Here the JSfiddle is based on the index.html/example.js files from the vue-promise-btn demo. The directive works well when the handler function doesn’t need any argument. However when we pass any argument to the handler, the handler returns “undefined” instead of returning the promise, thus the directive isn’t working.
It seems to me that the problem is very similar to this issue that you previously solved @STUkh https://github.com/vuejs/vue/issues/7705 because when I look the generated code for my handlers, I get:
Without arguments, valid return:
With arguments, missing return:
It seems that the “return” is missing for handlers with arguments, what do you think?
@SebastienTainon , @tradingstratagem - you can try v2.0.0 with extended mode - it fixes a lot of issues