Last active
January 18, 2021 12:23
-
-
Save TheFoot/a9f33f0486cc477b506bb06585ec857b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Display a vue component with bindings and return the props data | |
alertVue: async ( options, componentName, propsData ) => { | |
const ComponentClass = Vue.extend ( Vue.component ( componentName ) ); | |
const instance = new ComponentClass ( | |
{ | |
propsData: propsData | |
} | |
); | |
const result = await Swal.fire ( _.merge ( | |
{ | |
type : null, | |
allowOutsideClick: false | |
}, | |
options, | |
{ | |
html : '<div id="alertVue"></div>', | |
onBeforeOpen: () => { | |
instance.$mount (); | |
document | |
.getElementById ( 'alertVue' ) | |
.appendChild ( instance.$el ) | |
; | |
}, | |
preConfirm: () => instance.$props | |
} | |
) ); | |
// Destroy our dynamic instance | |
// Necessary? Not sure.. | |
instance.$destroy (); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment