Skip to content

Instantly share code, notes, and snippets.

@TheFoot
Last active January 18, 2021 12:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheFoot/a9f33f0486cc477b506bb06585ec857b to your computer and use it in GitHub Desktop.
Save TheFoot/a9f33f0486cc477b506bb06585ec857b to your computer and use it in GitHub Desktop.
// 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