question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling a function with parameters

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
SebastienTainoncommented, Nov 27, 2018

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:

on:{"click":function($event){$event.preventDefault();return dummyAsyncAction($event)}}}

With arguments, missing return:

on:{"click":function($event){$event.preventDefault();dummyAsyncAction('arg')}}}

It seems that the “return” is missing for handlers with arguments, what do you think?

0reactions
STUkhcommented, Feb 28, 2019

@SebastienTainon , @tradingstratagem - you can try v2.0.0 with extended mode - it fixes a lot of issues

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found