I have the next component, which is inside a modal tag. When clicking, the modal opens with the content fetched from said url.
<modal>
<laravel-view :url="'{{ '/post/view/' . $comment->source_id }}'"></laravel-view>
</modal>
It is defined here:
Vue.component('laravel-view',{
template: '#laravel-view.vue-template',
data(){
return {
viewHtml: null
}
},
props: [
'url'
],
mounted() {
this.loadPost(this.url)
},
methods: {
loadPost(viewUrl){
var self = this;
$.get( viewUrl, function( htmlString ) {
var compiled = Vue.compile('<div>' + htmlString + '</div>');
self.viewHtml = htmlString;
});
}
}
});
And the template, from a blade file:
<script type="text/x-template" id="laravel-view" class="vue-template">
<div class="view-wrapper" v-html=viewHtml>
</div>
</script>
When you click the laravel-view component, the modal opens (which is another component), and the content displayed would be the one it'd fetch from the link. This is the view returned from a controller with the information get from above:
<div>
<div class="post" style="text-align: center;">
<img src="{{ $post->image }}" style="margin: auto;" />
<p>
<h1 >{{ $post->title }}</h1>
{{ $post->caption }}
</p>
</div>
<div class="post-comments">
<div class="post-content">
@foreach( $post->comments as $comment )
<div class="comment activity-box-w" id="{{$comment->post_id}}">
<div class="activity-box" style="align-items: normal">
<div style="margin-top: 5px">
<div class="activity-avatar" style="background-image: url({{ asset($comment->image) }}); float: left;">
</div>
</div>
<div class="activity-info">
<div class="activity-role">
{{ '@' . $comment->username }}
</div>
<div class="ellipsis">
<div>
<p class="activity-title">{{ $comment->comment }}</p>
</div>
</div>
</div>
<div class="time">
{{ \Carbon\Carbon::parse($comment->created_at)->toDateTimeString() }}
</div>
</div>
</div>
@endforeach
</div>
<div class="post-pub" style="width: 100%;padding-top: 10px; margin-left: 25%;">
<form style="width: 100%:">
<textarea rows="1"></textarea>
<button type="button" class="btn-primary btn-s" v-on:click="commentPost">Send</button>
</form>
</div>
</div>
</div>
I've defined the method on both.js files (not that I need it on both; only to know where in the world it is triggered, assuming it does) and the event never triggers. I made sure the button worked by changing its type to "submit" and clicking it (which, reloaded the page). Still, the problem persists. How can I make this work?