0
Tó trying to make a reusable modal vuejs passing an object for editing or registration but I am locked in the way to pass the object asynchronously, since the object I want to pass will be changed when the user clicks the edit button for example.
The template is listed below:
<template>
<div>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
propE: {
type: Object
}
},
mounted() {},
data() {
return {};
},
methods: {
}
};
</script>
On the other hand, Component with the name "modalDinamic" has been added Given the object in the form of :
Prop:{
jose:'Miguel'
}
The statement remained:
<modal-dinamic :propE="Prop"></modal-dinamic>
To be more clear, in the parent element will have a method that will say that
this.Prop={
jose:'joaquin'
}
and thus gives a $('#myModal'). show(); I hope I’m clear now.
Can you show what you already have? or create a code example?
– Sergio
I added more data as you requested, created an example code
– Andersoney Rodrigues
Props are passed by reference. Are you sure the problem you’re describing really exists? Maybe I’m the one who didn’t get it right. That’s the one
Prop
is an object? then in modal you can access viathis.propE
.– Sergio
The problem is that this Prop will be updated, and the data is passed as if it were the first value that the object assumes, and the need is that it be dynamic.
– Andersoney Rodrigues
But as an object, the changes you make in one place are accessible elsewhere. Can you set an example that works with the problem? I’m happy to help
– Sergio
This Modal is jQuery?
– Sergio
Bootstrap, I used it for making the job easier
– Andersoney Rodrigues
And the above example the problem occurs.
– Andersoney Rodrigues
On the Vuejs website you have the example of modal, follow link: https://br.vuejs.org/v2/examples/modal.html. I hope you help.
– Bruno Rigolon