Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add additional argument for emit events - Quasar

I am using Quasar framework. And would like to add a 3rd argument on the framework component's preset.


This is for Q-popup-edit's save / cancel events:

Syntax:

@save -> function(value, initialValue)

Description

Emitted when value has been successfully validated and it should be saved

Parameters:

value - Validated value to be saved

initialValue - Initial value, before changes


Is there a way so that I do not have to specify the 'new' and 'old' value and just pass in my 3rd argument? @save="saved(.., .., arg3)" or something like @cancel="canceled(arg3)". If that is not possible, then how can I pass the initial and new values?

<q-popup-edit buttons lazy-rule v-model="props.row.value" @save=(newValue, initialValue, arg3)? 
...
methods: {
  saved (val, initialValue, arg3) {
    console.log(`original value = ${initialValue}, new value = ${val}`)
    console.log('argument3 = ' + arg3)
  },
  canceled (val, initialValue, arg3) {
    console.log(`retain original value = ${initialValue}, canceled value = ${val}`)  
    console.log('argument3 = ' + arg3)
  }
}
...

Quasar Q-popup-edit documentation: https://quasar.dev/vue-components/popup-edit

like image 411
kzaiwo Avatar asked Jan 23 '26 15:01

kzaiwo


1 Answers

You can achieve this.

example -

@filter="(val,update,abort) => yourFilterFn(val,update,abort,yourCustomParam)"



@save="(newValue, initialValue) => yourFilterFn(newValue,initialValue,third_argument)"
like image 80
Patel Pratik Avatar answered Jan 26 '26 06:01

Patel Pratik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!