figured out that I needed to run the processing of the modal-links on the next tick.
This commit is contained in:
parent
4a08cbf38d
commit
c83604c64d
5 changed files with 59 additions and 37 deletions
|
|
@ -173,8 +173,8 @@ function mapStringToModal(str) {
|
||||||
|
|
||||||
let params = linkToReplace.substring((dynamicStrings.MODAL_LINK).length + 2, linkToReplace.length -1)
|
let params = linkToReplace.substring((dynamicStrings.MODAL_LINK).length + 2, linkToReplace.length -1)
|
||||||
let splitParams = params.split(",");
|
let splitParams = params.split(",");
|
||||||
let bodyText = '<a href="#!" data-bs-toggle="modal" data-bs-target="#' + splitParams[0] + '" aria-label="Modal window">' + splitParams[1] +'</a>'
|
//let bodyText = '<a href="#!" data-bs-toggle="modal" data-bs-target="#' + splitParams[0] + '" aria-label="Modal window">' + splitParams[1] +'</a>'
|
||||||
|
let bodyText = '<a modalTarget="' + splitParams[0] + '" class="modal-text" aria-label="Modal window">' + splitParams[1] + '</a>'
|
||||||
return str.replace(linkToReplace, bodyText);
|
return str.replace(linkToReplace, bodyText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,8 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<recalModal cmsWidgetName="RecalModal" />
|
<recalModal ref="RecalModal" cmsWidgetName="RecalModal" />
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
@ -110,10 +109,23 @@ export default {
|
||||||
var damageString = getDamageString();
|
var damageString = getDamageString();
|
||||||
return damageString == "match" ? "" : damageString;
|
return damageString == "match" ? "" : damageString;
|
||||||
},
|
},
|
||||||
openModal(name)
|
|
||||||
{
|
|
||||||
$refs[name].openModal();
|
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const elements = document.getElementsByClassName("modal-text")
|
||||||
|
console.log(elements);
|
||||||
|
|
||||||
|
for(let element of elements){
|
||||||
|
console.log(element);
|
||||||
|
const target = element.getAttribute("modalTarget");
|
||||||
|
console.log("HERE!!!!" + target);
|
||||||
|
if(target)
|
||||||
|
{
|
||||||
|
console.log("HERE!!!!");
|
||||||
|
element.addEventListener("click", () => this.$refs[target].openModal() );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
|
|
@ -178,4 +190,5 @@ p strong {
|
||||||
color: #000000;
|
color: #000000;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
openModal() {
|
||||||
|
this.$refs[this.ModalName].openModal();
|
||||||
|
},
|
||||||
|
closeModal() {
|
||||||
|
this.$refs[this.ModalName].closeModal();
|
||||||
|
},
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
ModalName() {
|
ModalName() {
|
||||||
return this.cmsWidgetName;
|
return this.cmsWidgetName;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
here
|
here
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<a id="test" href="#!" aria-label="Modal window">Wow!!</a>
|
<a modalTarget="ModalName" class="modal-text" href="#!" aria-label="Modal window">Wow!!</a>
|
||||||
<siteFooter
|
<siteFooter
|
||||||
cmsWidgetName="SiteFooterWidget"
|
cmsWidgetName="SiteFooterWidget"
|
||||||
:isForwardActionDisabled="!meta.valid"
|
:isForwardActionDisabled="!meta.valid"
|
||||||
|
|
@ -60,24 +60,19 @@ export default {
|
||||||
openModal(modalName) {
|
openModal(modalName) {
|
||||||
this.$refs[modalName].openModal();
|
this.$refs[modalName].openModal();
|
||||||
},
|
},
|
||||||
clickModalButton() {
|
|
||||||
alert("you clicked me!");
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/* mounted: (
|
|
||||||
() => {
|
|
||||||
const element = document.getElementById("test");
|
|
||||||
element.addEventListener("click", () => app.openModal("ModalName") )
|
|
||||||
}
|
|
||||||
),
|
|
||||||
*/
|
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log(document.getElementById("test"))
|
const elements = document.getElementsByClassName("modal-text")
|
||||||
console.log(this.openModal);
|
const openModal = (modalName) => {
|
||||||
const element = document.getElementById("test");
|
this.$refs[modalName].openModal();
|
||||||
const modalname = "ModalName";
|
};
|
||||||
const openModal = this.openModal;
|
Array.from(elements).forEach((element) => {
|
||||||
element.addEventListener("click", () => openModal(modalname) )
|
const target = element.getAttribute("modalTarget");
|
||||||
|
if(target)
|
||||||
|
{
|
||||||
|
element.addEventListener("click", () => openModal(target) )
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
bodyText() {
|
bodyText() {
|
||||||
|
|
|
||||||
|
|
@ -57,4 +57,10 @@ body {
|
||||||
height: calc(100% - 72px);
|
height: calc(100% - 72px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-text {
|
||||||
|
display: inline;
|
||||||
|
color: $blue;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue